我是android的新手,jsut是一个非常简单的简单问题,如何在文本视图中添加底线,以便它在单元格的底部显示为1dp,这是迄今为止的代码:
<?xml version="1.0" encoding="UTF-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="47.5dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:paddingTop="13dp"
android:background="@drawable/line_str"
android:paddingLeft="8dp"
android:text="@string/manage_categories"
android:singleLine="true"
android:textColor="@color/white"
android:fontFamily="Roboto-Regular"
android:layout_gravity="center"
android:textSize="16sp"
/>
line_str.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the main color -->
<item>
<shape>
<solid android:color="@color/black" />
</shape>
</item>
<!-- This is the line -->
<item android:bottom="1dp">
<shape>
<solid android:color="#252525" />
</shape>
</item>
</layer-list>
任何帮助表示赞赏。谢谢!
答案 0 :(得分:6)
我将一个水平扩展的9patch图像并将其添加到textview的drawableBottom属性。
至于图层列表方法试试这个:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the main color -->
<item>
<shape>
<size android:height="@dimen/textViewHeight"/>
<solid android:color="@color/black" />
</shape>
</item>
<!-- This is the line -->
<item android:top="@dimen/textViewHeight">
<shape>
<size android:height="1dp"/>
<solid android:color="#252525" />
</shape>
</item>
</layer-list>