How to make Android apps compatible with different screen resolutions?

How to resize our application for different screens on different Android devices?

+3
source share
3 answers

If you want your layouts to work on different resolution screens, you must select them using dipas a device. For example:

android:layout_marginRight="10dip"

dip means Device Independent Pixel, and using them in your layout means that Android automatically scales your layout, depending on which display the device is running on which your application is running.

Android. , , dip, , .

+4

, , "dip" - .

, Heigth/Width, "dip" . 2 . , LinearLayout, RelativeLayout .. "fill parent", , . -, (), , /, G1/G2/ .. .

+1

logcat,

DisplayMetrics displaymetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);

        height = displaymetrics.heightPixels;
        width = displaymetrics.widthPixels;

If the screen size is displayed as 480x569, because of this, only the screen can be split at the end. To solve this problem, you must change the minSDK version number in the manifest file.

0
source

Source: https://habr.com/ru/post/1726429/


All Articles