繁体   English   中英

如何在Android中调整文字以适应屏幕尺寸?

[英]How can I make text adjust to the size of the screen in android?

到目前为止,我已经将页面设置为网格,使页面可以适应不同大小的屏幕。 有人告诉我使用不同的值文件,但我不希望这样做。 有没有办法让我的文字自然适应屏幕尺寸?

使用sp作为xml文件中的textSize属性的单位。

在这里您可以找到一个简单的示例:

http://developer.android.com/training/multiscreen/screendensities.html

或setTextSize在运行时:

http://developer.android.com/reference/android/widget/TextView.html#setTextSize%28float%29

您必须使用sp或dp。 这些单位是相对于屏幕尺寸的。

在TextView上,设置android:layout_width="fill_parent"而不是wrap_content。 然后在android:TextSize使用sp

暂无
暂无

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

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