简体   繁体   中英

Change color text and background color title of Popup Menu

How can i change color text and background color title of Popup Menu?

When i want change another item in popup menu i use something like this :

 <style name="itemTextStyle.customTheme" parent="@android:style/TextAppearance.Widget.IconMenu.Item">
    <item name="android:textColor">@color/green</item>
    <item name="android:textSize">10dp</item>
</style>

I would like to change only this tittle : ScreenShot

By getting the object of title, you can customize it

TextView alertTitle = (TextView) dialog.getWindow().getDecorView().findViewById(alertTitleId);
alertTitle.setTextColor(color);

ADD POPUPMENU TO Apptheme:

 <style name="AppTheme" parent="android:Theme.Light">
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
    </style>
    <style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
        <item name="android:popupBackground">@android:color/white</item>
    </style>

manifest.xml:

     <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
    .............
    </application>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM