我应该为Android中的不同设备创建多少大小的背景图像?
在这里,我有一个320X480图像(照片),并想把它作为我的背景图像在应用程序中我应该为Android中的不同设备创建多少大小的背景图像?,android,Android,在这里,我有一个320X480图像(照片),并想把它作为我的背景图像在应用程序中 <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"
<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"
android:background="@drawable/background">
</RelativeLayout>
但是,当我将它放在不同的设备中时,图像会变得非常奇怪(我不知道它是否奇怪,因为它是否重新调整了图像的大小)。那么,如何解决这个问题呢??
因为有一张照片,照片里只有一个人。如果一个人在设备A中看起来很瘦,但在设备B中看起来很胖,这会让人感到非常奇怪。有很多方法可以为全屏创建背景。我推荐的3种解决方案如下: 一个图像作为背景解决方案是最常用的解决方案。要实现这一点,您必须为每个主要屏幕大小制作一个图像=ldpi、mdpi、hdpi和xhdpi,并制作:
飞溅图像可以有任何大小,重要的是图像的外部部分混合到背景色中,这可以通过使具有背景色的图像慢慢混合到与背景相同的颜色中来实现
(4)的一个例子:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/black">
<FrameLayout
android:background="@drawable/splash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
>
</FrameLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/black">
<ImageView
android:background="@drawable/splash"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
>
</ImageView>
</RelativeLayout>