Linearlayout的android:divider属性

  • 这个属性可以在LinearLayout的每个子布局直间添加一个“drawable”作为分割线,这个drawable必须有设定好的高度或者宽度,因此不能直接设置为“@color/….”
  • 这个属性要和android:showDividers一起使用才会生效
  • android:showDividers有“begining”,“middle”,“end”,“none”四种值。默认值为“none”,即不显示分割线。

    你还在为开发中频繁切换环境打包而烦恼吗?快来试试 Environment Switcher 吧!使用它可以在app运行时一键切换环境,而且还支持其他贴心小功能,有了它妈妈再也不用担心频繁环境切换了。https://github.com/CodeXiaoMai/EnvironmentSwitcher


android:showDividers=”beginning”

<LinearLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:showDividers="beginning"
    android:orientation="vertical"
    android:divider="@drawable/list_divider"
    android:padding="@dimen/margin_normal">

    <Button
        android:text="sdf"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <Button
        android:text="sdf"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <Button
        android:text="sdf"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

LinearLayout>

只有第一个子控件上面有一条分割线
Linearlayout的android:divider属性_第1张图片

android:showDividers=”middle”

每个子空间之间都有一条分割线
Linearlayout的android:divider属性_第2张图片

android:showDividers=”end”

只有最后一个子控件有一条分割线
Linearlayout的android:divider属性_第3张图片

你可能感兴趣的:(Android)