【发布时间】:2021-05-18 12:39:24
【问题描述】:
我有一个文本视图,我希望它的背景是图像,并且它的角也是圆角的。我通过创建一个可绘制文件来尝试过,但背景图像被溢出了。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp"
android:padding="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="@color/colorPrimaryDark"
android:background="@drawable/drawable_file"
/>
</LinearLayout>
drawable_file.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap android:src="@drawable/img" />
</item>
<item>
<shape>
<stroke
android:width="1dp" />
<corners android:radius="50dp" />
</shape>
</item>
</layer-list>
【问题讨论】:
-
您能否展示一个您需要的示例输出
-
我已经添加了示例输出。
标签: android image textview shapes xml-drawable