【发布时间】:2017-10-09 22:43:04
【问题描述】:
【问题讨论】:
标签: javascript android xml
【问题讨论】:
标签: javascript android xml
我认为最好的方法是在所有视图后面使用 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>
【讨论】:
以编程方式,您可以这样做。 在不同的活动中,您可以使用相同的布局文件。 为您的布局命名:-myLayout 为布局定义一个变量。 受保护的视图 myLayoutView; 将布局读取为视图 myLayoutView = (View) findViewById (R.id.myLayout); 然后设置背景如下: myLayoutView.setBackground((Drawable) myBackground);
您在活动的 onCreate 方法中编写的所有上述内容。您可以随时更改背景。
布局中可能还有其他几个视图,它们可能会在屏幕上显示它们的内容,也可能有动画,但背景在所有这些之后保持静态。
【讨论】: