TextView无法使用Shape drawable设置drawableLeft(或Top,Right,Bottom)?

ide*_*pan 2 android shape textview drawable

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

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke android:color="#f00" android:width="2dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

然后我在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" />
Run Code Online (Sandbox Code Playgroud)

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

Ngu*_*iếu 6

试试这个!!!!

<?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>
Run Code Online (Sandbox Code Playgroud)