Android 文本视图可以';t设置可拉伸左(或顶部、右侧、底部)和可拉伸形状?

Android 文本视图可以';t设置可拉伸左(或顶部、右侧、底部)和可拉伸形状?,android,textview,drawable,shape,Android,Textview,Drawable,Shape,我定义了一个可绘制的形状,它是一条线 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <stroke android:color="#f00" android:width="2dp"/> </shape> 然后我在TextView的drawableBottom中设置了这个形状,但它不起作用 <TextView a

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

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


为什么以及如何让它工作?

一个解决方案是在textview下面添加一个单独的视图。因为您只需要一条线,所以请添加一个视图,并将高度设置为2dp,将背景色设置为#f00


试试这个

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


您是否尝试为形状中的笔划设置
android:height
属性?笔划没有“android:height”属性我知道此解决方案,但不想使用它。谢谢不,钥匙是
<?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>