0
votes

My app works perfectly in resolution 480x800. If I keep the 480x800 resolution but change the screen size to for example 2.7 inches, 3.7 inches or 5.4 inches it still is perfect. But when I change the resolution to for example 640x1066 all the ImageButtons is too small and in the wrong place in all screen sizes... I have created ImageButtons in all four folders(drawable-l, m, h, xh) but still the buttons is not in the correct size..

<ImageButton
android:id="@+id/ib1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="433dp"
android:background="@drawable/imagebutton1" />

<ImageButton
android:id="@+id/ib2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="188dp"
android:layout_marginTop="436dp"
android:background="@drawable/imagebutton2" />

NOTE: My problem is not when I change screen size, but when I change screen resolution.

2
Have you made sure to use dp instead of px wherever you specify explicit widths and heights? You might also want to post your XML layout so that we can see what you're doing to position your buttons. - kabuko
I use android:layout_marginLeft and marginTop to place the buttons correct in relative layout, should i use something else? - Peter
Depends... do you want all of your buttons relative to the left and top? Or perhaps more likely, do you want some to be relative to to the left/top some to be relative to the bottom/right? There's not one magical layout that will read your mind. You have to use the appropriate layout for the design. - kabuko
but my problem is not when i change screen size, but when i change screen resolution - Peter

2 Answers

2
votes

I would really like to see some code.

If you use RelativeLayout with attributes like android:layout_width and android:layout_height and specify values in dp (density pixels) e.g. android:layout_height="40dp" it should work just fine.

Please try to share some code with us.

0
votes

Make sure that your assets that you have in your ldpi, mdpi, hdpi and xhdpi folders are scaled correctly to accommodate the diff. resolutions. I accidentally scaled some assets incorrectly, and although they were in the correct folders..gave me some bad results

http://developer.android.com/guide/practices/screens_support.html