【发布时间】:2017-10-01 12:26:12
【问题描述】:
我必须在现有的 Android 应用程序上工作,其中所有文本都在布局 XML 文件中的 SP 单元中提及。
但是,应用程序的文本大小不会随系统字体一起调整。即,如果我从Settings -> Accessibility -> Font Size 更改系统字体大小,则应用程序的字体大小根本不会改变。
PFB 摘自我的布局文件,其中在 SP 中提到了 TextView's textSize。
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:padding="12dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:text="@string/find_an_noffice"
android:textSize="12sp"/>
</LinearLayout>
我认为这个问题与布局结构无关,因此我在示例应用程序中使用了相同的布局文件。此示例应用程序按预期工作。即应用的字体大小随系统字体调整。
我的原始应用程序没有像示例应用程序那样运行的可能性有哪些?
任何帮助将不胜感激。
【问题讨论】:
-
所以,要明确一点:同样的布局在 App A 中有效,但在 App B 中无效?如果是这样,这两个应用程序有什么不同?例如,它们的主题是否不同?
-
@CommonsWare:感谢您的评论。是的,相同的布局在 AppA 中而不是在 AppB 中工作。他们都使用相同的主题
Theme.AppCompat.Light.NoActionBar。这也是让我感到困惑的地方。字体不缩放还有其他可能性吗? -
什么都没想到。
-
@CommonsWare 我得到了解决方案。请看一看。
标签: android fonts sp scale-independent