gpt4 book ai didi

Android textview 颜色无故改变

转载 作者:行者123 更新时间:2023-11-30 02:19:11 31 4
gpt4 key购买 nike

今天我在装有 android 4.1 的设备上使用我的应用程序,我发现了一个非常烦人的错误。

每次我刷新屏幕时,textview 都无缘无故地改变了它们的颜色(例如:恢复 fragment )。

enter image description here

在此屏幕中,所有文本都是黑色的,但在这里它们都是白色的。有时有些是黑色的,有些是白色的。

这是我的应用程序中的一般 TextView 声明。

<TextView           
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="@string/overview"
android:textStyle="bold"
android:textAllCaps="true" />

这是我第一次在我的应用中看到这个错误。

编辑 1:

Fragment fragment = new Fragment_Overview();                    
fragmentManager.beginTransaction().add(R.id.fragment_container_1, fragment, "root").commit();

最佳答案

将此行添加到“values”-->“res”文件夹中的文件“strings.xml”:

<color name="black">#000000</color>

并将下一行添加到您的 TextView 定义中:

android:textColor="@color/black"

关于Android textview 颜色无故改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28841105/

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