我计划在不同的设备大小上为 textview 使用不同的字体大小,以使字母清晰易读。我已经决定不为不同的设备使用不同的布局,并建立了一个通用的布局来适应所有的设备。现在唯一的问题是文本大小。
问题:
我想就如何根据设备的大小(物理大小)更改字体大小获得您的技术建议。
如何根据纵横比推导出字体大小。
使用这种方法有什么缺陷吗?
TextView 的 XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical">
<TextView
android:id="@+id/tvValue4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="I planned to use different font size for the textview on different device size so as to make the letters legible. I have already decided not to use different layouts for different devices and built a common layout to fit in all the devices. Now the only problem is on the text size."
android:textColor="#000000"
android:textSize="15sp" />
</LinearLayout>
提前致谢
最佳答案
是的,这种方法是有缺陷的。 Android 设备具有不同的尺寸,但它们的密度也可能非常不同。
您应该只遵循 Android 设计 best practices .
他们实际上是经过深思熟虑的。为什么要重新发明轮子?
关于android - 根据设备大小增加字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15715324/