Java 如何在设备中将图像设置为适合屏幕的壁纸?
我想将应用程序中查看的图像设置为壁纸 尝试这样做时,图像不适合我的设备屏幕,但使用centerCrop可以正确查看图像 这是我的应用程序代码 活动\u main.xmlJava 如何在设备中将图像设置为适合屏幕的壁纸?,java,android,screen,android-wallpaper,Java,Android,Screen,Android Wallpaper,我想将应用程序中查看的图像设置为壁纸 尝试这样做时,图像不适合我的设备屏幕,但使用centerCrop可以正确查看图像 这是我的应用程序代码 活动\u main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
app:srcCompat="@drawable/image" />
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@color/transparent"
android:text="Set Wallpaper"
android:textColor="#ffffff" />
</RelativeLayout>
这是应用程序中使用的图像
实时应用程序屏幕
在安卓设备中设置壁纸后
如何将图像设置为XML文件(缩放到centerCrop)中使用的壁纸,以便将其设置为适用于任何android设备的完美壁纸?使用:
android:background="@drawable/image"
而不是:
app:srcCompat="@drawable/image"
设置为匹配家长尝试使用该图像,但没有结果我想将该图像设置为我的智能手机背景(壁纸)
app:srcCompat="@drawable/image"