Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

android - How do I change Item title font color for an Item that contains a menu in Navigation Drawer

I've been searching for a way to change a specific font color in my nav drawer. I can change the font colors for other item titles but not ones containing a menu.

<group
    android:id="something"
    android:checkableBehavior="single>
    <item
        android:title="Menu Heading>   <--This is what I want to change-->
        <menu>
            <item android:title="stuff"/> <--This i can change-->
            <item android:title="stuff"/>
        </menu>
    </item>
</group>    

I can change all other title colors with app:itemTextColor in the main activity. I've tried changing my theme's alternate font color. I'm still relatively new to programming in general, so I'm assuming I'm missing something. The only thing i can think of is to use action layout and just inflate a custom layout in the items, but I'd prefer to not redo all of my onClicks. As it is my designer wants dark menu and the text is defaulted to black regardless of theme changes so far.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To change the menu title instead of the individual item titles I just used html tags in the strings resource for color The title and referenced the strings xml as the title. This can be done for doing individual colors for each item also.

<string name="testTitle"><font color="#303F9F">The title</font></string>

<group
android:id="something"
android:checkableBehavior="single>
<item
    android:title="@string/testTitle">   <--This is what I want to change-->
    <menu>
        <item android:title="stuff"/> <--This i can change-->
        <item android:title="stuff"/>
    </menu>
</item>

I also noticed that this doesn't work if you have secondary text color in set in your styles.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...