![](/img/trans.png)
[英]How to support 2 different application icons on 2 different devices of same resolution in android?
[英]How to Set same text in Different Resolution in Android?
我想以不同的分辨率设置相同大小的文本。如何做到这一点。我还尝试通过创建两个新文件夹来进行布局,例如layout-small,layout-large,layout-xlarge,layout-normal。但仍然无法对其进行管理。请有人帮忙谢谢您。
在您的xml中使用类似的方法来设置文本的大小。 它与分辨率无关。
<TextView android:id="@+id/name_text"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textSize="10dp"
/>
或者您可以通过以下方式在Java代码中执行此操作
TextView text1 = (TextView) findViewById(R.id.txt);
text1.setTextSize(10);
如果您使用textSize =“ xdip”,它将根据分辨率进行调整;如果您使用textsize =“ xpx”,则文本大小将相同。
使用textSize =“ XXdp”(即,指定dp单位而不是px)以实现密度独立 。 这将在每个设备中以相同大小显示文本。 小布局,大布局等文件夹用于提供不同的布局(例如,手机的布局和平板电脑的不同布局),而不是文本大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.