i am trying to achieve theme like this but i can't find any help about it i am trying to get white action bar with black icons and text and status bar with black icons and white background I am changing color pragmatically but I think there is some proper theme to get something like this i have also tried material.theme.light
Here is your Solution
Try this
<?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.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white">
<android.support.v7.widget.Toolbar
android:id="#+id/ar_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="exitUntilCollapsed"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<TextView
android:id="#+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Nilesh Rathod"
android:textStyle="bold" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
Theme
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#android:color/white</item>
<item name="colorPrimaryDark">#android:color/white</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="colorControlNormal">#FFFFFF</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:statusBarColor">#android:color/white</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:navigationBarColor">#000</item>
</style>
OUTPUT
Related
My title bar looks like this:
I'm trying to make it transparent to get only the navigation icon & map full screen into the map view, but every time I am trying the transparent code to make the bar transparent it's ended up showing the white color.
I also try ed NoAction bar but its still ended up showing a white title bar.
Home_activity.xml
<RelativeLayout 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:background="#android:color/transparent"
android:scrollbars="horizontal">
<RelativeLayout
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="center"
android:background="#android:color/transparent"
android:fitsSystemWindows="true"
app:popupTheme="#style/Theme.AppCompat.NoActionBar">
</android.support.v7.widget.Toolbar>
<!-- The first child in the layout is for the main Activity UI-->
<FrameLayout
android:id="#+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="#+id/drawer_layout"
android:scrollbars="horizontal"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>
</LinearLayout>
<!-- Side navigation drawer UI -->
<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/navigation_header"
app:itemBackground="#drawable/naviagtionview_statecolor"
app:itemIconTint="#color/black"
app:itemTextColor="#color/black"
app:menu="#menu/my_navigation_items">
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
style.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/hint</item>
<item name="drawerArrowStyle">#style/MyDrawerArrowToggle</item>
<item name="colorPrimaryDark">#color/hint</item>
<item name="colorAccent">#color/black</item>
<item name="actionBarStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:background">#android:color/transparent</item>
<item name="android:backgroundStacked">#android:color/transparent</item>
<item name="android:displayOptions">showTitle</item>
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="drawerArrowStyle">#style/MyDrawerArrowToggle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance">
<item name="android:textColor">#color/black</item>
</style>
<style name="MyDrawerArrowToggle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">#color/black</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="EditText.Login" parent="Widget.AppCompat.EditText">
<item name="android:textColor">#android:color/black</item>
<item name="android:textColorHint">#android:color/darker_gray</item>
<item name="colorAccent">#color/yellow</item>
<item name="colorControlNormal">#color/black</item>
<item name="colorControlActivated">#color/yellow</item>
</style>
But it's showing like this:
I had a similar issue,
I used different ways to implement it,
you may try this to make toolbar transperent.
I have a toolbar.xml that is included to all activities
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ToolBarStyle"
app:popupTheme="#style/ToolBarStyle">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="#style/ToolBarStyle"
app:popupTheme="#style/ToolBarStyle"
app:subtitleTextColor="#color/secondaryTextColor"
app:titleTextAppearance="#style/Toolbar.TitleText"
app:titleTextColor="#color/primaryTextColor" />
</android.support.design.widget.AppBarLayout>
<View
android:id="#+id/toolbar_shadow"
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="#drawable/toolbar_drops_shadow" />
</LinearLayout>
On one of my activities I have back arrow and by default it's dark grey. I'd like to make it white. For this I create a theme
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryDark">#color/primaryDarkColor</item>
<item name="colorAccent">#color/secondaryColor</item>
<item name="android:textColorHint">#color/hintTextColor</item>
</style>
<!-- ToolBar -->
<style name="ToolBarStyle" parent="Widget.AppCompat.Toolbar">
<item name="android:gravity">center</item>
<item name="colorControlNormal">#FFF</item>
</style>
The problem is that this theme is not applied in KitKat to my toolbar. If I put <item name="colorControlNormal">#FFF</item> to AppTheme back arrow, menu icon become white. The problem is that it makes white some tints of EditText, everywhere.
Do you have an idea why this one does not work and how I can correctly apply a theme to the toolbar?
I want to make my toolbar transparent but don't know how?
`
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:theme="#style/TransparentToolbar"
android:background="#android:color/transparent">
</android.support.v7.widget.Toolbar>
All you need to is to define theme which hide action bar, define action bar style with transparent background and set this style to the toolbar widget. Please note that toolbar should be drawen as last view (over all view tree)
<style name="Theme.Custom" parent="#android:style/Theme.AppCompat">
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">true</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
<style name="CustomActionBar" parent="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>
</style>
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Toolbar should be above content-->
<include layout="#layout/toolbar" />
</RelativeLayout>
Toolbar layout:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="#style/CustomActionBar"/>
Using android.support.v7.widget.Toolbar, I find that it displays a weird shadow in devices with API > 19.
How it looks in Android 4.4.2 API 19:
How it looks in anything with API >19:
I'd need it to look like it does with API 19, where it does not have any shadows and rather "integrates" with the background.
Since I'm using this Activity with a DrawerLayout, I have 2 layouts.
activity_main_tabbed.xml
<?xml version="1.0" encoding="utf-8"?>
<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/main_tabbed_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="right">
<include
layout="#layout/activity_main_tabbed_content"
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="right"
android:fitsSystemWindows="true" />
</android.support.v4.widget.DrawerLayout>
activity_main_tabbed_content.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="#drawable/activity_background_vertical"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="#android:color/transparent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/action_bar_height"
android:elevation="0dp"
android:background="#android:color/transparent"
app:layout_scrollFlags="scroll|enterAlways">
<ImageView
android:layout_width="wrap_content"
android:id="#+id/btn_toolbar_back"
android:src="#drawable/left_white_arrow"
android:visibility="gone"
android:layout_height="match_parent"
android:layout_marginRight="#dimen/btn_back_toolbar_margin_right"
android:minHeight="#dimen/btn_back_toolbar_height"
android:minWidth="#dimen/btn_back_toolbar_width"
android:layout_gravity="left|center_vertical"/>
<rokk3rlabs.dingding.utils.views.FontTextView
android:layout_width="wrap_content"
android:textSize="#dimen/toolbar_text_size"
android:layout_height="wrap_content"
android:textColor="#color/colorPrimary"
android:text="#string/toolbar_title"
android:layout_gravity="left"
android:id="#+id/toolbar_title" />
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="#dimen/action_bar_height"
app:tabMode="fixed"
android:elevation="0dp"
app:tabGravity="fill"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<!-- <item name="android:windowBackground">#drawable/activity_background</item>-->
<item name="android:textColorPrimaryInverse">#color/colorPrimary</item>
<item name="android:textColorSecondaryInverse">#color/colorPrimary</item>
<item name="android:colorBackground">#color/colorPrimaryDark</item>
<item name="android:colorForeground">#color/colorPrimary</item>
<item name="android:textColorPrimary">#color/colorPrimary</item>
<item name="android:textColorSecondary">#color/colorPrimary</item>
<item name="android:windowBackground">#color/colorPrimary</item>
</style>
styles.xml (v21)
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimaryInverse">#color/colorPrimary</item>
<item name="android:textColorSecondaryInverse">#color/colorPrimary</item>
<item name="android:colorBackground">#color/colorPrimaryDark</item>
<item name="android:colorForeground">#color/colorPrimary</item>
<item name="android:textColorPrimary">#color/colorPrimary</item>
<item name="android:textColorSecondary">#color/colorPrimary</item>
<item name="android:navigationBarColor">#color/navigationBarColor</item>
<item name="android:statusBarColor">#color/statusBarColor</item>
<item name="android:windowBackground">#color/colorPrimary</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
Either make the AppBarLayout have a solid background or set its app:elevation="0dp" (not android:elevation).
Note: Why do you set every color to colorPrimary is puzzling. Purple text over purple background is not going to work. It also makes it impossible to know where the appbar layout ends and the activity background begins in the screenshot.
This is my current XML, with which i am getting the above output. How can i get the tint effect without overlapping the drawer?
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:weightSum="1">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
/>
</LinearLayout>
<com.heinrichreimersoftware.materialdrawer.DrawerView
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
I am using Systembar tint library by ready state softwares to get get transculent status bar on kitkat.
Add this to your theme, this will make your toolbar transparent
<item name="android:windowBackground">#android:color/transparent</item>
Add this in your colors xml for transparent color
<color name="transparent">#00000000</color>
Maybe this can help You:
Place all within a RelativeLayout with android:fitsSystemWindows="true":
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v4.widget.DrawerLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
</LinearLayout>
<com.heinrichreimersoftware.materialdrawer.DrawerView
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
EDIT/CREATE STYLES RESOURCES
/values/styles.xml:
<resources>
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorPrimary">#color/primary</item>
<item name="colorAccent">#color/accent</item>
<item name="android:windowBackground">#color/primary_dark</item>
</style>
</resources>
/values-v19/styles.xml: (for Kitkat)
<resources>
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
/values-v21/styles.xml: (for Lollipop)
<resources>
<style name="AppTheme" parent="AppTheme.Base"/>
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorAccent">#color/accent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
</resources>