我測試了仿真器和真實設備,但是您可以看到40 dp和40.2 dp之間沒有變化!我正在研究一個字體敏感度非常高的項目,問題在於android文本引擎的行爲。Android TextView小數尺寸問題
有什麼辦法可以防止這種情況發生?
請幫忙!
這是代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAMPLE TEXT"
android:textSize="40dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAMPLE TEXT"
android:textSize="40.2dp" />
</LinearLayout>
結果:
看到這個: https://stackoverflow.com/questions/23981260/should-use-sp-instead-of-dp-for-text-sizes – 2017-07-18 09:45:33
DP而不是使它SP和檢查 –