android studio中文本视图的带背景图像的圆角

问题描述

我有一个文本视图,我希望它的背景是一个图像,并且它的角是圆角的。我已经尝试通过创建一个可绘制文件来解决这个问题,但背景图像被溢出了。

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

Output:

Example Output:

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)