Toolbar weird elevation - android

If you set
App style:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Style:
<style name="AppTheme.Toolbar.ThemeOverlay" parent="Base.ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColorPrimary">#color/pickup_primary_text</item>
<item name="colorControlHighlight">#color/pickup_accent</item>
<item name="android:actionMenuTextColor">#color/pickup_primary_text</item>
<item name="android:textColorSecondary">#color/pickup_primary_text</item>
<item name="android:background">#color/pickup_primary</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
<item name="android:elevation">4dp</item>
</style>
Toolbar:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:toolbar="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?actionBarSize"
android:theme="#style/AppTheme.Toolbar.ThemeOverlay"
toolbar:titleTextAppearance="#style/AppTheme.Toolbar.TitleText" />
But if I set it directly in the toolbar
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:toolbar="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:minHeight="?actionBarSize"
android:theme="#style/AppTheme.Toolbar.ThemeOverlay"
toolbar:titleTextAppearance="#style/AppTheme.Toolbar.TitleText" />
I thought it was a bug but they say that not.
Why?

Related

ScrollView doesn't work with ConstraintLayout inside Fragment

I have a ScrollView and a ConstraintLayout with some views inside, but it is not scrolling. I saw in other related questions some advice to add:
android:fillViewport="true"
to the layout and I ever tried with NestedScrollView and change the position of ScrollView, but nothing helps.
My fragment layout is:
<ScrollView
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:fillViewport="true"
>
<android.support.constraint.ConstraintLayout
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/layout_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:paddingEnd="?attr/listPreferredItemPaddingRight"
android:paddingStart="?attr/listPreferredItemPaddingLeft"
android:paddingTop="?attr/listPreferredItemPaddingLeft"
>
<TextView
android:id="#+id/lbl_style"
style="#style/HeadSection"
android:text="#string/label_style"
app:layout_constraintStart_toStartOf="#+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="#+id/txt_beer_description"/>
<TextView
android:id="#+id/lbl_short_style"
style="#style/Label"
android:text="#string/label_short_style"
app:layout_constraintStart_toStartOf="#+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="#+id/lbl_style_name"/>
<TextView
android:id="#+id/txt_short_style"
style="#style/Content"
app:layout_constraintStart_toStartOf="#+id/guideline_content_margins"
app:layout_constraintTop_toBottomOf="#+id/txt_style_name"
tools:text="American Dark Lager"/>
<TextView
android:id="#+id/lbl_style_name"
style="#style/Label"
android:text="#string/label_style_name"
app:layout_constraintStart_toStartOf="#+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="#+id/lbl_style"/>
<TextView
android:id="#+id/txt_style_name"
style="#style/Content"
app:layout_constraintStart_toStartOf="#+id/guideline_content_margins"
app:layout_constraintTop_toBottomOf="#+id/lbl_style"
tools:text="American-Style Dark Lager"/>
<TextView
android:id="#+id/lbl_style_category_name"
style="#style/Label"
android:layout_height="19dp"
android:text="#string/label_style_category_name"
app:layout_constraintStart_toStartOf="#+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="#+id/lbl_short_style"/>
<TextView
android:id="#+id/txt_style_category_name"
style="#style/Content"
app:layout_constraintStart_toStartOf="#+id/guideline_content_margins"
app:layout_constraintTop_toBottomOf="#+id/txt_short_style"
tools:text="North American Lager"/>
<TextView
android:id="#+id/lbl_beer"
style="#style/HeadSection"
android:layout_marginLeft="16dp"
android:layout_marginTop="4dp"
android:text="#string/label_detail_head_beer_info"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="#+id/lbl_beer_name"
style="#style/Label"
android:text="#string/label_detail_beer_name"
app:layout_constraintStart_toStartOf="#+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="#+id/lbl_beer"/>
<TextView
android:id="#+id/txt_beer_name"
style="#style/Content"
app:layout_constraintStart_toStartOf="#+id/guideline_content_margins"
app:layout_constraintTop_toBottomOf="#+id/lbl_beer"
tools:text="Heineken"/>
<TextView
android:id="#+id/lbl_beer_Description"
style="#style/Label"
android:text="#string/label_detail_beer_description"
app:layout_constraintStart_toStartOf="#+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="#+id/lbl_beer_name"/>
<TextView
android:id="#+id/txt_beer_description"
style="#style/Content"
android:layout_width="0dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/guideline_content_margins"
app:layout_constraintTop_toBottomOf="#+id/lbl_beer_Description"/>
<android.support.constraint.Guideline
android:id="#+id/guideline_label_margins"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="16dp"/>
<android.support.constraint.Guideline
android:id="#+id/guideline_content_margins"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="120dp"/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
This layout is inflated in a fragment that is:
content_detail.xml:
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/fragment_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
/>
And the root layout:
<?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:id="#+id/layout_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="#dimen/card_height_huge"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include
layout="#layout/content_detail"/>
</android.support.design.widget.CoordinatorLayout>
-- EDIT
there is a bug report about this behavior.
I found a bug that was supposed to be fixed, but some others users related still report the issue:
https://issuetracker.google.com/issues/37115702
-- EDIT
I rotate the phone, the txt_beer_description TextView goes off the screen. So if I scroll the scroll works until the end of txt_beer_description, no more.
-- EDIT
style file is:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#android:color/black</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="SearchBeerItemBaseText">
<item name="android:gravity">start|center_vertical</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginStart">8dp</item>
</style>
<style name="SearchBeerItemTextPrimary" parent="SearchBeerItemBaseText">
<item name="android:textColor">#color/primary_text</item>
<item name="android:textSize">16sp</item>
</style>
<style name="SearchBeerItemTextSecundary" parent="SearchBeerItemBaseText">
<item name="android:textColor">#color/secondary_text</item>
<item name="android:textSize">14sp</item>
</style>
<style name="CollectionItemBaseText">
<item name="android:gravity">start|center_vertical</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="CollectionItemTextPrimary" parent="CollectionItemBaseText">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">15sp</item>
<item name="android:focusable">false</item>
<item name="android:focusableInTouchMode">false</item>
<item name="android:clickable">false</item>
</style>
<style name="CollectionItemTextSecundary" parent="CollectionItemBaseText">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">13sp</item>
</style>
<style name="SearchActivityPrimaryImage">
<item name="android:layout_width">56dp</item>
<item name="android:layout_height">56dp</item>
</style>
<style name="HeadSection">
<item name="android:layout_marginTop">16dp</item>
<item name="android:layout_marginBottom">8dp</item>
<item name="android:textStyle">bold</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#color/primary</item>
<item name="android:textAppearance">#style/TextAppearance.AppCompat.Subhead</item>
</style>
<style name="Label">
<item name="android:textStyle">bold</item>
<item name="android:layout_marginTop">16dp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#color/primary_text</item>
<item name="android:textAppearance">#style/TextAppearance.AppCompat.Body1</item>
</style>
<style name="Content" >
<item name="android:layout_marginTop">16dp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#color/secondary_text</item>
<item name="android:textAppearance">#style/TextAppearance.AppCompat.Body1</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
</resources>
In your ScorllView, change layout_height to:
android:layout_height="wrap_content"
The problem is related with the appbar:
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="#dimen/card_height_huge"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
/>
I shouldn't use app:layout_behavior in that.

Android : Toolbar Subtitle Gravity Right Not Working

I want to create actionbar subtitle but its gravity should be right. It should end at title end. Please see following image
My Style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
</style>
<style name="FullscreenTheme" parent="AppTheme">
<item name="android:actionBarStyle">#style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="android:background">#color/black_overlay</item>
</style>
<style name="ToolbarSubtitleAppearance" parent="#style/TextAppearance.Widget.AppCompat.Toolbar.Subtitle">
<item name="android:textSize">10sp</item>
<item name="android:layout_gravity">right</item>
<item name="android:layout_width">match_parent</item>
</style>
</resources>
Toolbar in Layout File :
<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>
Can i achieve this via doing small changes because i had included in many layout file.
make your toolbar like this so your can custimize as you want
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
app:popupTheme="#style/AppTheme.PopupOverlay"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="title "/>
<TextView
android:id="#+id/subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="sub title "/>
</LinearLayout>
</android.support.v7.widget.Toolbar>

Status bar overlaps action bar in android

I have tried many ways to make action bar place in bottom of status bar but still not working, I am using API 17,I have added android:fitsSystemWindows="true" in CoordinatorLayout but still not working
Here is my code:
the main_activity:
<net.aparteman.apartemanapp.viewHolder.SlidingMenuLayout 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="match_parent">
<android.support.design.widget.NavigationView
android:id="#+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#color/dark_purple"
android:fitsSystemWindows="true"
android:layoutDirection="rtl"
android:textDirection="rtl"
app:elevation="0dp"
app:headerLayout="#layout/dashboard_nav_header"
app:itemTextColor="#color/white"
app:menu="#menu/dashboard_drawer_view"
app:theme="#style/ApartemanStyle" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<include
android:id="#+id/actionbar"
layout="#layout/dashboard_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#+id/dashboard_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
the dashboard_bar.xml :
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
app:popupTheme="#style/AppTheme" />
</android.support.design.widget.AppBarLayout>
style.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="ApartemanStyle" parent="Theme.AppCompat.Light">
<item name="android:textSize">16sp</item>
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
<item name="contentInsetStart">0dp</item>
<item name="contentInsetEnd">0dp</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="ApartemanStyle.NoActionBar">
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="ApartemanStyle.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="ApartemanStyle.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
It looks like this:
Can anyone help me on this?

Android Support Toolbar shadow API > 19

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.

Background color of Toolbar in Lollipop is normal but in Kitkat is white

In Lollipop, The background color of toolbar was shown normally, but in KitKat, it was shown as white color.
I don't know why.
activity_main.xml
<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=".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>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay"
parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
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>
Try putting your AppBarLayout at the end of you code. Apparently your included layout is overlapping the ToolBar. That happened to me and I fixed it doing that, it just came to my mind. Like this:
<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=".MainActivity">
<include layout="#layout/content_main"/>
<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>
</android.support.design.widget.CoordinatorLayout>
Create a base theme in styles.xml with primary colors and other colors colors then set it as parent in styles.xml-v21 for your style name="AppTheme.NoActionBar".
Below is my example :
in styles.xml
<style name="AppBase" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary_color</item>
<item name="colorPrimaryDark">#color/primary_color_dark</item>
<item name="colorAccent">#color/primary_yellow_bright</item>
<item name="colorControlNormal">#color/primary_yellow</item>
<item name="colorControlHighlight">#color/primary_color_light_100</item>
<item name="colorControlActivated">#color/primary_yellow_bright</item>
<item name="colorButtonNormal">#color/primary_yellow_bright</item>
<item name="android:windowBackground">#color/primary_white</item>
<item name="android:textColorPrimary">#color/primary_color</item>
<item name="android:textColorSecondary">#color/primary_color_light</item>
<item name="android:textColor">#color/primary_white</item>
<item name="android:buttonStyle">#style/ButtonAppTheme</item>
</style>
<style name="AppTheme" parent="AppBase" />
in styles.xml-v21
<style name="AppTheme" parent="AppBase">
<item name="android:navigationBarColor">#color/primary_light_gray</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">#android:transition/move</item>
<item name="android:windowSharedElementExitTransition">#android:transition/move</item>
</style>
in AndroidManifest.xml
android:theme="#style/AppTheme"
should work.

Categories

Resources