我想在前台创建一个带TextView的视图,并且可以在背景中设置图像和颜色。 这是我期待的观点图像。
我尝试使用setBackgroundView()方法进行设置,但它接受图像或颜色。 我怎样才能达到这个效果? 提前谢谢。
答案 0 :(得分:0)
替换字符串,大小和可绘制内容以匹配您的内容。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/purple_50">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/pattern"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/widget_margin"
android:text="@string/content"
android:gravity="center"
android:textSize="@dimen/text_content"/>
</FrameLayout>