简体   繁体   English

需要标准比例的值在不同的dimens.xml android

[英]Need Standard proportion of values in different dimens.xml android

I'm confused about the values that we use in values/dimens.xml. 我对在values / dimens.xml中使用的值感到困惑。

For ex. 对于前者 if I've declared the below dimension for text size in values/dimens.xml 如果我在values / dimens.xml中为文本大小声明了以下维度

<dimen name="text_30">30sp</dimen>

then what should be an equivalent value of 30sp in values-sw600dp/dimens.xml and values-w820dp/dimens.xml ? 那么在值-sw600dp / dimens.xml和values-w820dp / dimens.xml中应该是30sp的等价值? Is there any proportion/formula that we need to apply while putting values in these different dimens.xml ? 在将值放入这些不同的dimens.xml时,是否需要应用任何比例/公式?

Also same question for dp values as well. 对于dp值也是同样的问题。

Thanks in advance. 提前致谢。

You will have to calculate for different devices and that's a lengthy way. 你将不得不计算不同的设备,这是一个漫长的方式。 you can do something like mentioned here . 你可以做这里提到的事情

TextView text = new TextView(this);
text.setText("text");
text.setTextSize(16 * getResources().getDisplayMetrics().density);

This will always show same text size for all the devices. 这将始终显示所有设备的相同文本大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM