---
title: "【Android Study】怎样更“高端”地建立分割符"
author: "crazysumer"
date: "2014-06-23T22:00:34Z"
tags: []
categories: ["移动开发"]
slug: "android-study"
draft: false
lastmod: "2014-06-23T22:00:34Z"
id: 2084129
url: "https://crazysumer.iteye.com/blog/2084129"
---

![](http://dl2.iteye.com/upload/attachment/0098/3988/e0094f3e-d926-378e-92b8-67682c4c25b1.png)  
 

       像这样的分隔符，通常我们首先想到的是用两个1px的View去做分隔符，在API 11 （Android ）以及之后，又更人性的实现方式

 

   1.separator.xml

 

 

```
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
 <size android:width="1dp" />
 <solid android:color="#90909090" />
</shape>
```

    

 

   2.在布局中使用

 

```
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:divider="@drawable/separator"
    android:showDividers="middle"
    android:orientation="horizontal">
 
    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/buttonBarButtonStyle"
        android:text="Yes"
        android:layout_weight="1"
        android:id="@+id/button1"
        android:textColor="#00b0e4" />
 
    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/buttonBarButtonStyle"
        android:text="No"
        android:layout_weight="1"
        android:id="@+id/button2"
        android:textColor="#00b0e4" />
 
    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/buttonBarButtonStyle"
        android:text="Neutral"
        android:layout_weight="1"
        android:id="@+id/button3"
        android:textColor="#00b0e4" />
 
</LinearLayout>
```

  

 

 

 

来源： http://envyandroid.com/archives/1193/view-separators?utm\_source=Android+Weekly&utm\_campaign=ac89b26b9e-Android\_Weekly\_107&utm\_medium=email&utm\_term=0\_4eb677ad19-ac89b26b9e-337843225