【问题标题】:Android: how to change title bar color of popup using xml stylesAndroid:如何使用 xml 样式更改弹出窗口的标题栏颜色
【发布时间】:2018-03-23 20:50:55
【问题描述】:

我有以下样式表,但弹出标题仍然是白色的。如何使用 xml 样式进行更改?

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.Splash" parent="android:Theme">
        <item name="android:windowBackground">@drawable/splash</item>
        <item name="android:windowNoTitle">true</item>
    </style>

    <style name="YellowWarning" parent="android:Theme">
        <item name="android:textColor">@color/yellow</item>
    </style>

    <style name="FloodSearchTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/FloodSearchTheme.ActionBarStyle</item>
        <item name="android:textColor">#ffffff</item>
        <item name="android:editTextStyle">@style/FloodSearchTheme.EditTextStyle</item>
        <item name="android:itemBackground">#333333</item>
    </style>

    <style name="FloodSearchTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:titleTextStyle">@style/FloodSearchTheme.ActionBar.TitleTextStyle</item>
        <item name="android:background">#333333</item>
    </style>

    <style name="FloodSearchTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
        <item name="android:textColor">#ffffff</item>
    </style>

    <style name="FloodSearchTheme.EditTextStyle" parent="@android:style/Widget.EditText">
        <item name="android:background">#ffffff</item>
        <item name="android:textColor">#000000</item>
        <item name="android:padding">10dp</item>
    </style>
</resources>

这里是代码...

    public override void OnCreateContextMenu(IContextMenu menu, View v, IContextMenuContextMenuInfo menuInfo)
    {
        base.OnCreateContextMenu(menu, v, menuInfo);
        if (v.Id != Resource.Id.historyListView) return;

        menu.SetHeaderTitle("Options");  commenting this out bc i can't figure out how to make the title bar white, doesnt seem to be a style associated and google searches have turned up nothing
        menu.Add("Edit");
        menu.Add("Delete");
        menu.Add("Share via Email");
        menu.Add("Share via Text");
        menu.Add("Get Full Report");
    }

【问题讨论】:

  • 你用的是什么控件? PopupWindow? AlertDialog?你能显示关于你的popup 的代码吗?或者你能描述一下你的popup 是如何显示的吗?我无法理解你的问题。
  • 这是出现在 Droid 活动上的弹出菜单,如果您按住并按下控件。您可以自定义内容,顶部标题栏是我由于某种原因无法设置的样式。似乎它应该是显而易见的和容易的,但事实并非如此。
  • 我的弹出菜单没有标题,您介意告诉我如何显示带有标题的弹出菜单吗?
  • 我更新了我的问题以包含代码。谢谢。

标签: android xamarin


【解决方案1】:

您是否尝试过设置 android:windowTitleStyle? Here's 是一个类似的问题

【讨论】:

    猜你喜欢
    • 2022-08-15
    • 2017-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-03
    • 1970-01-01
    相关资源
    最近更新 更多