我打算在不同設備大小的文本視圖中使用不同的字體大小,以使字母易讀。我已決定不針對不同設備使用不同的佈局,併爲所有設備構建了通用佈局。現在唯一的問題是文字大小。根據設備的大小增加字體大小
問題:
我想就如何改變設備的基礎上,大小字體大小(物理尺寸)的技術建議。
如何根據縱橫比導出字體大小。
任何使用這種方法的缺陷?
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>
在此先感謝
picpaste.com/Untitled1-4MSIpnIo.png請查看屏幕截圖我已經使用了的TextView的15dp。但是這在不同設備中以不同數量的線顯示。我需要擁有相同行數的所有屏幕。如果屏幕尺寸小,字體必須小,如果屏幕尺寸大,那麼字體必須變大。請傳遞您的建議 - iappmaker – iappmaker
dp(或dip)是與設備無關的像素,而不是「設備像素」 。請參閱http://developer.android.com/guide/topics/resources/more-resources.html#Dimension您的文章的其餘部分每英寸大約160個點以及其他所有內容大多數都是正確的。我只是在迂腐。 –