Development issue/problem:

Edited question:

Moving resolution : I would like to develop different screen dpi’s, like the following resolutions.
320×480,480×800,540×960,720×1280 (Samsung S3),1080×1920 (S4, Nexus5,Nexus 5x, Motorcycle G4),2560×1440 (Nexus 6, Nexus 6p, Samsung Edge) Tablet resolution
: 480×800 (Micromax),600×1024 (Samsung tab2),800×1280 (Nexus 7),1200×1920 (New Nexus 7),2048×1536 (Nexus 9).

I want to use different font sizes depending on the screen resolution of the device.

Q1) What is the best way to solve this problem?

Q2) What is the best option – drop encoding or XML?

Q3) In which folder is the resolution of the device displayed?

Q4) What is the size of the application launch icon for different resolutions?

How can I solve this problem?

Solution 1:

Application thrower icon size in pixels for different resolutions

Moving resolution

  • mipmap-mdpi (48X48)
  • mipmap-hdpi (72X72)
  • Mip Card Exhaust Pipe (96X96)
  • mip-xxhdpi card (144X144)
  • mip-xxxhdpi card (192X192)

Shelf arrangement:

Use the following folders if you want a specific layout for your tablet:

(1024×600)(800×1280)(1200×1920)(128 00)(2560×1600)

Drawing folders:

  1. Mobile

red/signettable (standard) red/signable dpi/ (240×320 and above) red/signable dpi/ (320×480 and above) red/signable ddpi/ (48 00, 54 60 and above) red/signable ddpi/ (720×1280 – Samsung S3, Micromax HD Canvas etc.) red/signable ddpi/ (48 00, 54 60 and above) red/signable ddpi/ (720×1280 – Samsung S3, Micromax HD Canvas etc.(1080×1920 – Samsung S4, HTC one, Nexus 5 etc.)res/signable-xxhdpi/(1440X2560 – Nexus 5 etc.).etc.). res/ removable-xxhdpi/ (1080×1920 – Samsung S4, HTC one, Nexus 5 etc.)res/ removable-xxhdpi/ (1440X2560 – Nexus 6,Samsung S6edge).

  1. Tablet resolution :
    Different resolution support android –

Font size:

NOTE: Always try to use SP when working with textSize, for example. B. textize=12sp

  1. Use the predefined textImage :

It automatically adjusts the text size to the density of the device.

Use of samples :

  1. Use dimension.xml for each device:

From the Google IO Pdf you can see the structure below:

    1. Mobile:

res/values/dimens.xml (standard)res/values-ldpi/dimens.xml (240×320 and higher resolution)res/values-mdpi/dimens.xml (320×480 and higher resolution)res/values-hdpi/dimens.xml.xml (48 00, 54 60 and higher resolution)res/values-xxhdpi/dimens.xml (720×1280 – Samsung S3, Micromax Canvas HD, etc.)res/values-xxhdpi/dimens.xml (1080×1920 – Samsung S4, HTC one, etc.)

res/value-xxxhdpi/dimens.xml (1440X2560 – Nexus 6,Samsung S6edge).

    1. Tablet:

For the tablet, more specific folders can be used, such as large, valuable folders.

res/values-large/dimens.xml (48 00)res/values-large-mdpi/dimens.xml (600×1024)


res/values-sw600dp/dimens.xml (600×1024)
res/values-sw720dp/dimens.xml (800×1280)
res/values-xlarge-xhdpi/dimens.xml (2560×1600 – Nexus 10)
res/values-large-xhdpi/dimens.xml (1200×1920 – Nexus 7(last))

For more information :

See Supporting multiple screens.
For more information on device density, see the Google IO pdf on page 77. Here you will find a way to work with dimens.xml for different devices.
Prepare your Nexus 6 and Nexus 9 applications.

Extract of the multiscreen support:

A density independent pixel corresponds to a physical pixel on a
screen at 160 dpi, which is the basic density assumed by the
system for a medium density screen. During operation, the
system transparently handles any necessary scaling of the dp units based on the current
screen density. The conversion of dp units to
screen pixels is simple: px = dp * (dpi / 160). For example, on a 240 dpi
screen, 1 dp corresponds to 1.5 physical pixels. When defining the user interface for your application, you should always use dp
devices to ensure that your
user interface is displayed correctly at different screen densities.

Solution 2:

First create folders with different values for the different screens.and place the size corresponding to screen
in the file res->values->dimens.xml and call the single font size with @dimen/text_size.


// for the little ones


// for a normal life


//in general


// on a large scale


and restore the font size in TextView as follows.

Solution 3:

To avoid problems with different screen resolutions and densities, I place and position everything according to the width and height of the screen as a percentage. By adjusting the text to the percentage of the screen width or height, the font will have the correct size on all devices and in all resolutions. To get the correct font size for the width and height of the room, you can use this function:

private float SetTextSize(String text, int width, int height)
paint paint = new Paint();
float textWidth = paint.measureText(text);
float textSize = (int) ((width / textWidth) * paint.getTextSize());
paint.setTextSize(textSize) ;

textWidth = paint.measureText(text) ;
textSize = (int) ((width / textWidth) * paint.getTextSize() ) ;

// Measure again with the font size next to our desired result
paint.setTextSize(textSize) ;

// check height restrictions
FontMetricsInt metrics = paint.getFontMetricsInt();
floattextHeight = metrics.descent – metrics.ascent;
as (textHeight > height)
textSize = (int) (textSize * (height/textHeight));
return textSize;

Here is the code to determine the width and height of the screen:

Point Size = new Point();
screenWidth = size.x ;
screenHeight = size.y ;
display display = getWindowManager().getDefaultDisplay() ;
screenWidth = display.getWidth() ;
screenHeight = display.getHeight() ;

To get the correct font size, simply create a range based on the width and height of the screen and adjust it until the font size seems correct. Once you’ve done it right, it should be clearly visible on all devices.

float textSize = SetTextSize (text, (int) (screenWidth * 0.1), (int) (screenHeight * 0.15)) ;

I hope this helps you

Solution 4:

Basically, you have to create a text style, something like this:

More information can be found here at

And by using the Android guide to support different screens, you can create different formats for different screens in the appropriate folder, as described at

Accompanying note : I’m not sure I know what situation you’d want to do it in. By using SP units for font size, fonts can be scaled to approximately the same size on different phones.

Solution No 5:

First, the draft of your resolution request.

For example: Assuming the resolution of your mobile phone is 380*480.

Width of the mobile phone screen : 380

Text Image size 80dp
Assumption: If the width is 380dp, then 100%.

the display width of the text is 80dp, how much %(per) is there then.

The answer to the question: The answer to the question: The answer to the question: The answer to the question: The answer to the question: Reply: 25 %

determine the screen size programmatically with the pigeon formula

DisplayMetrics displaymetrics = new DisplayMetrics();
ScreenHeight = displaymetrics.heightPixels;
ScreenWidth = displaymetrics.widthPixels;
txt_height = (int)((ScreenHeight*14.58)/100);
txt_width = (int)((ScreenWidth*37.5)/100) ;

LinearLayout.LayoutParams normal_param = new LinearLayout.LayoutParams(txt_height,txt_width ) ;

txt_Name.setLayoutParams(normal_param) ;

Solution No 6:

I think that’s a good answer:

Text size and different Android screen sizes

But here’s how you do it with the screen resolution:

You can create a resource value directory for each permit as follows

values-WWIDTHp-HIGHTdp (you can also use WWIDTHp or values-HIGHTdp)
, for example: 320*480 becomes values-w320p-h480dp

Create in each folder (including the default values folder) a file named dimens.xml with the contents :

z. B. (resolution related value):

You can now use @dimen/def_font_size
or create a style in the default values folder.

Add this to the styles.xml file:

Solution No 7:

I’ve created a function that adjusts the size of the dp to the size of the screen, and it works well for me. If you have problems with the size of the text on the screen, try this.

public float convertFromDp(int input) {
final float scale = getResources().getDisplayMetrics().density;
return ((input – 0,5f) / scale);

is simply by assigning the defined value to the size of the text display, as shown below.

tvTextView1.setTextSize(convertFromDp(24)) ;

Solution No 8:

To support nexus 6, create a 560 dpi rendering folder and place all images in it.

Good luck!

recover deleted files from htc phone,how to recover deleted videos from htc desire,android recovery-transfer,android android data recovery,www android recovery net android data recovery html download,android phone soft android data recovery,data recovery android,recycle bin in htc desire

You May Also Like

Optimize Your WordPress Website and Its Content

Looking for a WordPress A/B testing plugin to experiment on your site…

Why You Should Buy Montblanc Watches

Last update: 4 seconds Exotic Irfan Fine timepieces: If you are a…

How To Boost Your Internet Speed

  There is nothing more annoying than the slowness of the Internet.…

Problems In Your Air Conditioner- Fix It Like A Pro

In this age of global warming, one of the inevitable and inseparable…