Android:工具栏文字颜色

Android:工具栏文字颜色,第1张

概述我正在尝试在我的工具栏中使用主题.我想改变文字颜色,但我不能这样做,我不知道为什么.文字颜色没有被应用,而不是棕色,它看起来像黑色.你能帮我么?styles.xml<resources><stylename="AppTheme"parent="Theme.AppCompat.Light.NoActionBar"></style><stylena

我正在尝试在我的工具栏中使用主题.我想改变文字颜色,但我不能这样做,我不知道为什么.文字颜色没有被应用,而不是棕色,它看起来像黑色.你能帮我么?

styles.xml

<resources>    <style name="Apptheme" parent="theme.AppCompat.light.NoActionbar">    </style>    <style name="Apptheme.Toolbar.Title" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">        <!-- Set proper Title size -->        <item name="androID:textSize">@dimen/abc_text_size_Title_material_toolbar</item>        <item name="androID:gravity">center</item>        <item name="androID:textcolor">@color/brown</item>    </style></resources>

layout.xml

<androID.support.v7.Widget.Toolbar        xmlns:androID="http://schemas.androID.com/apk/res/androID"        xmlns:app="http://schemas.androID.com/apk/res-auto"        androID:ID="@+ID/toolbar"        androID:layout_alignParentBottom="true"        androID:layout_wIDth="match_parent"        androID:layout_height="70dp"        androID:background="@drawable/toolbar_main"        >        </androID.support.v7.Widget.Toolbar>

colors.xml:

<?xml version="1.0" enCoding="utf-8"?><resources>    <item name="brown" type="color">#b78c07</item>    <integer-array name="androIDcolors">        <item>@color/brown</item>    </integer-array></resources>

解决方法:

您可以以编程方式设置工具栏标题颜色

Random rnd = new Random(); Toolbar.setTitleTextcolor(color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));

这会设置一个随机颜色,在运行时,您可以添加您喜欢的颜色.
color.RED,color.BLUE等

谢谢

总结

以上是内存溢出为你收集整理的Android:工具栏文字颜色全部内容,希望文章能够帮你解决Android:工具栏文字颜色所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1116140.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存