我计划在不同设备上使用不同的字体大小,以使文字清晰易读。我已决定不为不同设备使用不同的布局,并建立了一个通用布局以适应所有设备。现在唯一的问题是文本大小。
问题:
请提供您在基于设备尺寸(物理尺寸)调整字体大小方面的技术建议。
如何根据纵横比确定字体大小。
使用这种方法有哪些缺陷?
文本视图的 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>
提前致谢
dp
是密度无关像素,对应于在160dpi下一个物理像素的大小。sp
也是基本单位,但根据用户首选的文本大小进行缩放(它是一个比例无关的像素),因此在定义文本大小时应使用此测量单位(但永远不要用于布局大小)。请参阅http://developer.android.com/training/multiscreen/screendensities.html。 - CrandellWS