android linearlayout下划线
时间: 2023-09-25 09:06:13 浏览: 141
可以使用View控件来实现下划线效果,具体实现方式如下:
1. 在LinearLayout中添加一个View控件,设置宽度为match_parent,高度为1dp,背景颜色为下划线颜色。
2. 将View控件的layout_marginTop属性设置为需要的下划线距离上方控件的距离。
示例代码如下:
```
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="这是一个TextView"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"
android:layout_marginTop="8dp"/>
</LinearLayout>
```
效果如下图所示:
注意:如果LinearLayout中有多个控件需要添加下划线,可以在每个控件下方添加一个View控件。如果需要动态添加下划线,则需要在代码中创建并添加View控件。
阅读全文
相关推荐


















