![](/img/trans.png)
[英]Set Current WallPaper As Application's Background in JetpackCompose
[英]Set Wallpaper on application background
我正在制作一個應用程序,我想在應用程序背景上設置壁紙,而不是在主屏幕背景上。 那里的任何人都可以指導我如何做到這一點?
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>
請注意,BackGround 或 Image 視圖應始終位於其他視圖之上
<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>
正如我所評論的,您需要執行以下操作 - 假設您想設置應用程序主屏幕的背景。 您可以設置您的 XML layout
父視圖的背景,或者您可以使用相對布局將ImageView
作為底層和在其上方的其余視圖。 現在您可以根據需要設置ImageView
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.