首页 > 代码库 > Android Shape Divider

Android Shape Divider

 

  安卓框架提供了一种LinearLayout 内部布局元素分割线的实现,建立一个指定长宽的矩形Shape:

 1  <?xml version="1.0" encoding="utf-8"?> 2  <shape xmlns:android="http://schemas.android.com/apk/res/android" 3      android:shape="rectangle"> 4  5      <size 6         android:width="@dimen/spacing_medium" 7         android:height="@dimen/spacing_medium" /> 8  9     <solid android:color="@android:color/transparent" />10 11 </shape>

作为LinearLayout的Divider属性引入:

 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2     android:layout_width="match_parent" 3     android:layout_height="wrap_content" 4     android:divider="@drawable/spacer_medium" 5     android:orientation="vertical" 6     android:padding="@dimen/spacing_medium" 7     android:showDividers="middle"> 8  9     <!-- TextView -->10 11     <LinearLayout12         android:id="@+id/buttons_container"13         android:layout_width="match_parent"14         android:layout_height="wrap_content"15         android:divider="@drawable/spacer_medium"16         android:orientation="horizontal"17         android:showDividers="middle">18 19         <!-- Buttons -->20 21     </LinearLayout>22 23 </LinearLayout>

 

Android Shape Divider