I currently have an imageview with an image. It looks perfect on my 2.7″ test screen, however, when I test it on my 4.3″ screen, the image is not where it should be. I am setting the height to have dp and I have my image file in hdpi, mdpi, and Ldpi folders. Am I doing something wrong? Or rather, is there some way to lock the place of the image so that it displays the same way in all phone sizes?
Thanks.
The imageview that is not adjusting to various screen sizes is the first imageview (id = sdrbg)
here’s my layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<ImageView android:layout_width="wrap_content"
android:layout_alignParentTop="true" android:id="@+id/sdrbg"
android:background="@drawable/sdrmaingraphic" android:layout_height="289dp"></ImageView>
<ImageView android:id="@+id/canvasBOM"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="false" android:layout_width="fill_parent"
android:background="@drawable/canvas" android:layout_height="100dp">
</ImageView>
<Button android:layout_alignParentBottom="true"
android:id="@+id/playpausebuttonBOM" android:background="@drawable/main_pause_button"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_marginLeft="10dp"></Button>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/nextbuttonBOM"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" android:background="@drawable/next_song_button"
android:layout_marginRight="10dp"></Button>
<TextView android:id="@+id/textView1" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Best of May 2011"
android:textSize="20dp" android:textStyle="bold"
android:layout_centerHorizontal="true" android:layout_centerVertical="false"></TextView>
</RelativeLayout>
Instead of specifying the height use
wrap_contentand RelativeLayout features to specify height. For example:android:layout_alignParentTop="true" android:layout_alignBottom="@id/playPauseButtomBOM"andandroid:layout_marginBottom="xxdp"