Android 在LinearLayout上设置背景图像
是否有一种方法可以将背景图像添加到线性布局中,以便在其上绘制按钮控件?我试图查看是否有办法将位图作为线性布局的背景,但找不到方法。您可以使用xml标记Android 在LinearLayout上设置背景图像,android,Android,是否有一种方法可以将背景图像添加到线性布局中,以便在其上绘制按钮控件?我试图查看是否有办法将位图作为线性布局的背景,但找不到方法。您可以使用xml标记android:background=“@drawable/yourbackground”或通过setBackgroundResource(int)通过代码进行设置使用框架布局,放置图像视图,然后放置线性布局,如下所示: <FrameLayout xmlns:android="http://schemas.android.com/a
android:background=“@drawable/yourbackground”
或通过setBackgroundResource(int)通过代码进行设置
使用框架布局,放置图像视图,然后放置线性布局,如下所示:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:srcCompat="@drawable/chrysanthemum"
android:contentDescription="@string/todo" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/quan"
android:layout_width="107dp"
android:layout_height="56dp"
android:gravity="center"
android:text="quantity"
android:textAllCaps="true"
android:textColor="#000000" />
</LinearLayout>
</FrameLayout>