【问题标题】:Customizing Toolbar and other properties inside SettingsActivity在 SettingsActivity 中自定义 Toolbar 和其他属性
【发布时间】:2016-01-12 10:09:46
【问题描述】:

我正在尝试在 SettingsActivity 中自定义我的应用程序的样式。我想更改 状态栏工具栏 颜色,如果可能的话,还想更改 窗口背景(从深灰色到浅灰色)和 text 颜色(例如将白色更改为黑色)。我已经阅读了许多网站,并且在 style.xml 中尝试了不同的选项,但没有成功。在 SettingsTheme 中,colorPrimarycolorPrimaryDark 不会覆盖父主题的默认颜色。提前致谢。

这是我的应用的主要活动

这是我现在的设置活动

style.xml

<resources>

    <!-- application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="colorPrimary">#3F51B5</item>
        <item name="colorPrimaryDark">#1A237E</item>
        <item name="colorAccent">#FFEB3B</item>
        <item name="android:windowBackground">@color/custom_background_light_grey</item>
        <item name="dropDownListViewStyle">@style/PopupMenuListView</item>

    </style>

    <style name="PopupMenuListView" parent="@style/Widget.AppCompat.Light.ListView.DropDown">
        <item name="android:divider">#FF0000</item>

        <item name="android:dividerHeight">2dp</item>
        <item name="android:background">#3F51B5</item>
    </style>

    <style name="SettingsTheme" parent="ThemeOverlay.AppCompat.ActionBar">
        <item name="colorPrimary">#3F51B5</item>
        <item name="colorPrimaryDark">#1A237E</item>
    </style>


</resources>

xml 中的工具栏

<android.support.v7.widget.Toolbar
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary">

    </android.support.v7.widget.Toolbar>

【问题讨论】:

    标签: android android-toolbar


    【解决方案1】:

    您确定在设置中使用工具栏吗?可能你忘了在设置活动中添加“NoActionBar 主题”?

    (我知道这可能不是答案,但由于声誉问题,我无法发表评论。)

    【讨论】:

      【解决方案2】:

      请在您的设置活动工具栏代码中替换上述代码。

      <android.support.v7.widget.Toolbar
                      android:id="@+id/toolbar"
                      android:layout_width="match_parent"
                      android:layout_height="?attr/actionBarSize"
                      android:background="?attr/colorPrimary"
                      app:popupTheme="@style/AppTheme.PopupOverlay" />
      

      【讨论】:

        猜你喜欢
        • 2011-09-09
        • 1970-01-01
        • 2019-03-02
        • 1970-01-01
        • 2010-11-15
        • 1970-01-01
        • 1970-01-01
        • 2015-07-27
        • 2020-04-24
        相关资源
        最近更新 更多