首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Java Android,默认的文本视图颜色是灰色,看起来像是提示文本的颜色,该怎么纠正呢?

Java Android,默认的文本视图颜色是灰色,看起来像是提示文本的颜色,该怎么纠正呢?
EN

Stack Overflow用户
提问于 2020-10-19 16:25:39
回答 2查看 80关注 0票数 2

文本颜色为灰色,如下所示,我没有在sytles.xml中设置任何默认颜色。正如您所看到的,微调器文本颜色和文本视图颜色之间存在差异。

color difference between Spinner and textview text

代码语言:javascript
运行
复制
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView color"
    android:textAlignment="gravity"
    android:textAllCaps="false"
    android:textSize="16dp"
    android:textStyle="bold"
    android:gravity="left|center"
    android:layout_marginLeft="20dp"
android:padding="12dp"    />


    <Spinner
        android:layout_width="192dp"
        android:layout_height="49dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:entries="@array/spinner_items"
        android:padding="10dp"
        android:spinnerMode="dropdown"

         />

我运行了ColorStateList oldColors = textView.getTextColors();,得到了下面的结果。

代码语言:javascript
运行
复制
ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[-16842910], []]mColors=[603979776, -1979711488]mDefaultColor=-1979711488}

文本颜色是由于此样式,我的Styles.xml:

代码语言:javascript
运行
复制
 <resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

我想要的就是普通的黑色文本。我不想添加任何更改。

EN

回答 2

Stack Overflow用户

发布于 2020-10-19 16:28:49

在TextView中添加颜色属性

<文本视图

android:color="#000000"

          android:layout_width="wrap_content“

          android:layout_height="wrap_content“

颜色“TextView          android:text=”

          android:textAlignment=“地心引力”

          android:textAllCaps="false“

          android:textSize="16dp“

          android:textStyle=“粗体”

          android:gravity=“左|中”

          android:layout_marginLeft="20dp“

          android:padding="12dp“/>

票数 1
EN

Stack Overflow用户

发布于 2020-10-19 22:15:30

看起来这是文本的默认颜色。所以我不得不强制它在Styles.xml中使用普通的黑色

代码语言:javascript
运行
复制
<item name="android:textColor">@color/textColorPrimaryLight</item>

我寻找的原因是我想实现黑暗模式。下面的文章对我的问题有帮助。基本上我必须使用2个styles.xml来实现暗模式。

How to officially support Dark Mode in your apps?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64423652

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档