然后我在TextView的drawableBottom中设置了这个形状,">
我定义了一个可绘制的形状,它是一条线。
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke android:color="#f00" android:width="2dp"/>
</shape>
然后我在TextView的drawableBottom中设置了这个形状,但是它没有工作。
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:drawableBottom="@drawable/shape_line"
android:drawablePadding="5dip"
android:text="Hello World" />
为什么和怎样才能让它发挥作用?
发布于 2016-04-22 01:12:14
试试这个!
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<size
android:height="1dp"
android:width="500dp" />
<solid android:color="#f00" />
</shape>
发布于 2016-04-21 23:26:05
一种解决方案是在文本视图下面添加一个单独的视图。因为您只想要一条线,请添加一个视图并将高度设置为2dp,背景色设置为#f00
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:drawableBottom="@drawable/shape_line"
android:drawablePadding="5dip"
android:text="Hello World" />
<View
android:layout_width="wrap_content"
android:layout_height="2dp"
//set your custom color
</View>
https://stackoverflow.com/questions/36787416
复制相似问题