我测试了仿真器和真实设备,但是您可以看到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和检查 –