gpt4 book ai didi

android - 如何防止系统字体大小改变对 Android 应用程序特定部分的影响?

转载 作者:行者123 更新时间:2023-12-04 15:25:14 26 4
gpt4 key购买 nike

系统范围内的“字体大小”设置允许调整文本大小。

它通常运行良好,但在某些情况下会发生特殊情况, View 的特定部分应忽略此设置并且字体大小应保持不变。

我知道 how to prevent system font-size changing effects to android application?

但是现在(Android 10)无法使用 dp 接受的答案(https://stackoverflow.com/a/21546897/4130619)

https://stackoverflow.com/a/57225687/4130619删除整个 Activity 中的缩放,https://stackoverflow.com/a/39346113/4130619移除整个应用中的缩放。

受影响的代码,dp 尝试已经使用(并且失败):

            <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:id="@+id/compassNorth"
android:layout_alignParentTop="true"
android:text="@string/compass_north_one_letter"
android:textColor="#000"
android:textSize="10dp"/>

N (compass_north_one_letter) 无论如何都在改变大小:

enter image description here

最佳答案

试试 autoSizeTextType,它可以让文本大小根据可用的 View 大小自动缩放。 https://developer.android.com/guide/topics/ui/look-and-feel/autosizing-textview

它允许您指定最大尺寸、预设尺寸,以便您可以进行更多控制。我不了解您的整个布局,因此无法实际测试,但可以从您的代码 fragment 中进行测试,例如,

        <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:id="@+id/compassNorth"
android:layout_alignParentTop="true"
android:text="@string/compass_north_one_letter"
android:textColor="#000"
app:autoSizeTextType="uniform"
/>

此外,我认为您需要指定具有特定大小的 layout_height 以限制自动调整大小的 View 大小。如果它不起作用,请尝试 app:autoSizeMaxTextSize,或者也可以进行粒度调整。

关于android - 如何防止系统字体大小改变对 Android 应用程序特定部分的影响?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62396130/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com