user1227605
user1227605

Reputation: 9

Screen Size in android

i have created an application in android but when i test my application on different screen sizes android phones then look and feel is not stable.

My question is how to set your application display for all android phones?

Upvotes: 0

Views: 264

Answers (2)

Housefly
Housefly

Reputation: 4422

Best way is to use relative layout instead of hardcode values like layout_height = "20dp" or else use two types of layouts 1 each for landscape & portrait, this should solve maximus of your issues. but there is another way to get exactly the same for every screen, by dynamically setting the view attributes...this was

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

    int height = metrics.heightPixels;
    int width = metrics.widthPixels;

    Button Button1 = (Button) findViewById(R.id.button1);
    Button Button2 = (Button) findViewById(R.id.button2);
    Button1.setWidth(width / 2);
    Button2.setWidth(width / 2);

Upvotes: 0

Sulabh Gajjar
Sulabh Gajjar

Reputation: 501

 Android has included support for three screen-size “buckets” since 1.6,
based on these “dp” units: “normal” is currently the most popular device format (originally 320x480, more recently higher-density 480x800); 
“small” is for smaller screens, and “large” is for “substantially larger” screens. 
Devices that fall in the “large” bucket include the Dell Streak and original 7” Samsung Galaxy Tab. 
Android 2.3 introduced a new bucket size “xlarge”, in preparation for the approximately-10” tablets (such as the Motorola Xoom) that Android 3.0 was designed to support.

xlarge screens are at least 960dp x 720dp.

large screens are at least 640dp x 480dp.

normal screens are at least 470dp x 320dp.

small screens are at least 426dp x 320dp.
(Android does not currently support screens smaller than this.)

Upvotes: 2

Related Questions