我定义了一个可绘制的形状,它是一条线。

<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" /> 

为什么以及如何让它发挥作用?

请您参考如下方法:

试试这个!!!!

<?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> 


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!