[英]How to change Item title background in the navigation drawer in Android?
I have have a group of items in a navigation drawer menu: 我在导航抽屉菜单中有一组项目:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Group Title">
<menu>
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_camera"
android:icon="@drawable/ic_star_black_24dp"
android:title="Import" />
<item
android:id="@+id/nav_gallery"
android:icon="@drawable/ic_share_black_24dp"
android:title="Gallery" />
</group>
</menu>
</item>
</menu>
I managed to style the menu items following the instruction in this post from stack overflow. 我设法样式的菜单项中的指令之后这个帖子从堆栈溢出。 Basically modifying these three properties:
基本上修改这三个属性:
This works fine except it only styles the items inside the tag: 效果很好,只是它仅对标签内的项目设置样式:
So my question is: how can I style (color and background) the titles ("Show Apps" and "Others")? 所以我的问题是:如何设置标题(“显示应用程序”和“其他”)的样式(颜色和背景)?
add following codes in styles.xml 在styles.xml中添加以下代码
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:itemBackground">#00F</item>
<item name="android:itemTextAppearance">@style/TextAppearance</item>
</style>
<style name="TextAppearance">
<item name="android:textColor">#F00</item>
</style>
change first line "name" and "parent" with your app defaults 使用您的应用默认值更改第一行“名称”和“父”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.