在应用背景上设置壁纸

时间:2015-07-31 18:49:41

标签: android wallpaper setting

我正在制作一个应用程序,我想在应用程序背景上设置壁纸,而不是在主屏幕背景上。 谁能指导我如何做到这一点?

3 个答案:

答案 0 :(得分:1)

image extension not required....

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SecondActivity">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/hello"/>

 <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="hello"
    android:layout_centerInParent="true"/>


</RelativeLayout>

答案 1 :(得分:1)

Note that BackGround or the Image view should always on top of other view

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="centerCrop"
    android:src="@drawable/bu"/>

<TextView android:text="@string/hello_world"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="40dp"
    android:textSize="45sp"/>
<TextView android:text="Good_Day"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:padding="40dp"
    android:textSize="45sp"/>

</RelativeLayout>

答案 2 :(得分:0)

As I have commented you need to do following - Suppose you want to Set a background of your Apps Main Screen. You can set the background of your parent view of your XML layout or you can have an ImageView as bottom layer and rest view above this using the relative layout. And now you can set the ImageView as you wish.

相关问题