(Android学习)设置分割线

两种方法

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:divider="@drawable/fengexian"
    android:showDividers="middle"
    android:dividerPadding="10dp">

   <!--设置分割线1:使用LinearLayout的一个divider属性-->

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="按钮1" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="按钮2" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="按钮3" />

<!--    设置分割线2-->
    <View
         android:layout_width="match_parent"
         android:layout_height="3px"
         android:background="#000000" />
    
</LinearLayout>

在这里插入图片描述
参考:
为LinearLayout设置分割线

猜你喜欢

转载自blog.csdn.net/weixin_45625639/article/details/122899309