我使用actionbarsherlock.下面的代码片段负责将其背景更改为自定义代码.
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="background">@drawable/actionbar_bg</item>
<item name="android:background">@drawable/actionbar_bg</item>
<...>
</style>
<style name="Theme.MyApp" parent="@style/Theme.Sherlock.Light">
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
<..>
</style>
Run Code Online (Sandbox Code Playgroud)
它适用于actionbarsherlock(在蜂窝下面的版本).但是在ICS中,我在动作栏下面有一个阴影,我不想要.什么样的项目让它消失?
我在一个活动我使用工具栏更改颜色Palette,但使用5.0的设备ActionBarActivity的status bar颜色是我的颜色colorPrimaryDark我的活动主题,所以我有2个非常不同的颜色和它看起来并不好.
我意识到在5.0你可以使用,Window.setStatusBarColor()但ActionBarActivity没有这个.
所以我的问题是在5.0中如何更改状态栏颜色ActionBarActivity?
我正在使用Android Studio中使用的模板AppCompat Toolbar.不幸的是,工具栏在状态栏上投下阴影,因此看起来不正确.我也实现了一个,NavigationDrawer所以我不能简单地设置状态栏的颜色.
这是它的样子:
这应该是这样的:
activity_main.xml中
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
app_bar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="hu.pe.thinhhoang.aaosync.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<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" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
styles.xml(v21)
<resources>>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)