Hi,
I have a larger image of 1024 x 768. When the image is displayed in the android device as the background image then it gets compressed. Is there any way that the image can be displayed properly in all screen resolution?
Hi,
I have a larger image of 1024 x 768. When the image is displayed in the android device as the background image then it gets compressed. Is there any way that the image can be displayed properly in all screen resolution?
You are talking about multiple screen support. You need to make 3 types of images, HDPI, MDPI and LDPI. They have all different aspect ratios as well as different sizes.
Check out my tutorial on this subject, should explain everything.
http://wonton-games.blogspot.com/2010/07/tutorial-multiple-screen-support.html
or a simpler method if you just want to keep your aspect ratio is in your xml file using imageView do this
<ImageView
android:id="@+id/background"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/background"
android:adjustViewBounds="true">
</ImageView>
What this does is keep the aspect ratio of the image and fit it to the screen. You will get bars on either side if the aspect ratio doesn't match but this is just a quick shortcut way. You might have to play with layout_width/height to make it fit properly.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
android:background = "@drawable/titlepage">
</RelativeLayout>
This is the code that I am using for setting the background image. But since the image is quite large it appears to be compressed when viewed on emulator or device.
Any help will be just great.