Reputation: 564
Nexus 10 holds 2500*1600 resolution whereas the previous neighbor in the same density family holds 1024*800 - ** DOUBLE **
My concern is completely on images, I already hold images of x*x px, If I use the same image in Nexus - it stretches ?
How to handle these type of resolutions ?
Upvotes: 1
Views: 2742
Reputation: 902
you can determine the size of the screen by code and then apply the necessary code. for example, I need to change text size base on different screen resolution.
public void setMainButtonTextSize(){
if (isXLargeScreen()){
mainButtonTextSize = 38;
mainButtonDownTextSize = 32;
titleTopButtonTextSize = 80;
titleBottomButtonTextSize = 60;
timeTextSize = 36;
dayTextSize = 26;
dateTextSize = 36;
} else if (isLargeScreen()){
mainButtonTextSize = 28;
mainButtonDownTextSize = 22;
titleTopButtonTextSize = 70;
titleBottomButtonTextSize = 50;
timeTextSize = 26;
dayTextSize = 16;
dateTextSize = 26;
} else if (isNormalScreen()){
mainButtonTextSize = 18;
mainButtonDownTextSize = 14;
titleTopButtonTextSize = 40;
titleBottomButtonTextSize = 30;
timeTextSize = 16;
dayTextSize = 12;
dateTextSize = 16;
} else if (isSmallScreen()){
mainButtonTextSize = 12;
mainButtonDownTextSize = 10;
titleTopButtonTextSize = 30;
titleBottomButtonTextSize = 20;
timeTextSize = 12;
dayTextSize = 8;
dateTextSize = 12;
}
}
public Boolean isLargeScreen(){
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
return true;
} else
return false;
}
public Boolean isNormalScreen(){
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
return true;
} else
return false;
}
public Boolean isSmallScreen(){
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
return true;
} else
return false;
}
public Boolean isXLargeScreen(){
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
return true;
} else
return false;
}
depending on the return value, i change the text size accordingly.
Upvotes: 0
Reputation: 564
The points in this thread are generic tips to design layouts for multiple screen-
I got the answer -
We can even sub categorize the drawable's depending on resolution using drawing-sw1200-xhdpi
Regards SS
Upvotes: -1
Reputation: 592
http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources
You should have alternative resources depending on screen resolution.
For example if you want alternative layout for extra large screens, you need to place the alternative layouts in layout-xlarge. The general rule is resources_name-qualifier. You can find out about the options in the android guide for supporting multiple resolutions and screen sizes: http://developer.android.com/guide/practices/screens_support.html
Upvotes: 1
Reputation: 62
Arun chandravanshi
Handle multiple resolutions in android:
1) In android Application project anatomy 4 folder 1) hdpi,mdpi,ldpi and xhdpi (in res folder ) you can put your images here for multiple screen size devices. The system automatically choose images from these folder according to device.
2) use sp instead of dp when give font size.
3) us dp in place of px.
4) Mostly us Linear layout and Relative layout instead of other layout.
5) Use 9 patch images.
6) Avoid using of Absolute layout.
7) use png images.
8) use layout-land folder for landscape mode.
Thanks.
Upvotes: 0
Reputation: 2236
There are many possible ways to achieve this one of the major thing is using components size
width -- height in dp, text size in sp
other is you can use layout-ldpi, layout-mdpi, layout-hdpi, layout-xhdpi
dp and sp will solve your problem
Upvotes: 1