Reputation: 3291
I have a background image which is 1280 X 720 that fits my S3 so much.
However, if I want to fit other devices, how to do it?
For example, if one device is 800 X 600, if I scale the image from 1280 X 720 to 800 X 600, the image will a little bit out of shape.
Also, I want the image to fit fullscreen size.
Is there any good idea?
After I research, I know that I should prepare different resolution images, but which resolutions should I prepare?
Upvotes: 0
Views: 220
Reputation: 28152
If you don't have an image that can be used as a 9-patch then I'd suggest something like following:
<?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"
<ImageView
android:src="@drawable/backgroundimage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"/>
</RelativeLayout>
This solution will give you an image that covers whole the screen. The image will be uniformly stretched but some parts will be cut out as it uses centerCrop.
Upvotes: 2
Reputation: 4222
You can use 9patch graphics. Find draw9patch.bat in your Android/tools directory. You put your PNG file through this utility, and mark the areas of the graphic that can be stretched to fit the display.
Upvotes: 1