繁体   English   中英

分别更改背景颜色和操作栏颜色

[英]Change background colour and action bar colour separately

我正在尝试将我的应用程序和actionBar的背景色更改为不同的颜色:

<!-- Base application theme. -->
<style name="actionBar" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/veniceblue</item>


</style>

<style name="AppTheme" parent="Theme.AppCompat">
    <item name="android:background">@drawable/background_template</item>
    <item name="actionBarTheme">@color/veniceblue</item>
</style>

但是我在清单文件中添加:

 android:theme="@style/actionBar">

但是我不确定如何同时添加背景? 我确实希望为整个应用程序设置它吗?

对不起,如果我不明白您的问题(我只是一个尝试学习和帮助的初学者),可以使用android.support.v7.widget.Toolbar

layout.xml

<android.support.design.widget.AppBarLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:theme="@style/AppTheme.AppBarOverlay"
    android:id="@+id/appBarLayout">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>

和style.xml

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="AppCompaTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@color/primaryColor</item>
    <item name="colorPrimaryDark">@color/primaryColorDark</item>
    <item name="android:textColorPrimary">@android:color/white</item>
    <item name="android:windowNoTitle">true</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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