答案 0 :(得分:0)
我认为最好的方法是在所有视图后面使用ImageView(可以使用framelayout)这里是你的xml: (您可以使用不同的scaleType)
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@mipmap/background"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- put your views here -->
</RelativeLayout>
</FrameLayout>
答案 1 :(得分:0)
以编程方式,您可以这样做。 在不同的活动中,您可以使用相同的布局文件。 为您的布局命名: - myLayout 为布局定义变量。 受保护的视图myLayoutView; 阅读布局作为视图 myLayoutView =(查看)findViewById(R.id.myLayout); 然后设置背景如下: myLayoutView.setBackground((Drawable)myBackground);
您在活动的onCreate方法中写的以上所有内容。您可以随时更改背景。
布局中可能还有其他几个视图可能在屏幕上显示其内容,但也可能有动画,但背景在所有这些背后仍然是静态的。