应该是什么在Android的多个设备密度的文字大小比例是多少? [英] What should be the text size ratio in android for multiple density device?
问题描述
我在做多屏幕设备的Android应用程序。
我想知道什么应该针对不同的密度的设备文字大小规模的比例是多少?
I am making an Android application for multiple screen device. I want to know what should be the text size scale ratio for different density device?
例如:如果我的文字大小 MDPI
设备上28sp那么应该是什么样的华电国际
设备?
example : if my text size is 28sp on mdpi
device then what should be on hdpi
device?
我在价值观LDPI
,价值观MDPI
,值,华电国际
等,并定义梦诗
每个相应值文件夹的文字大小,但它并没有看所有的设备类似。
I made values-ldpi
, values-mdpi
, values-hdpi
etc. and define text size in dimens
of each respective values folder, but it did not look similar on all device.
推荐答案
您不需要知道的比,你不应该直接使用它们,因为密度的数量保持了变化。
You dont need to know the ratios, and you shouldnt directly use them since the amount of densities keep changin.
如果您在资源使用它,使用SP单元将做到这一点在每一个密度做工精细,无diferent值的文件夹。
If you use it in the resources, using the sp unit will do it work fine in every density, without diferent value folders.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="type1">28sp</dimen>
</resources>
如果您从code这样做,可能会显得diferent取决于howyou ASIGN值。你必须正确值发送到setTextSizeFunction,例如:
If you do it from code, probably it will look diferent depending on howyou asign the values. You have to send the correct values to the setTextSizeFunction, for example:
setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.type1));
//he documentation method that COMPLEX_UNIT_PX returns a Resource dimension value multiplied by the appropriate metric.
或硬codeD编号:
setTextSize(TypedValue.COMPLEX_UNIT_SP, 9);
这篇关于应该是什么在Android的多个设备密度的文字大小比例是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!