Android screen size resolution

2019-02-21 07:22发布

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条回答
Anthone
2楼-- · 2019-02-21 07:51

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.

查看更多
\"骚年 ilove
3楼-- · 2019-02-21 08:02

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

查看更多
登录 后发表回答