1

For information, I am using Android Studio 2.0 Preview 7, API 23.

Activity that is having the issue Activity that doesn't apply the theme

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="in.ezyride.blovia.OfferRide"
    android:fitsSystemWindows="true">
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"
        android:id="@+id/view">

        <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>
    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/view">
        <include
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:id="@+id/basicLayoutAddl"
            layout="@layout/content_offer_ride"
            />
    </ScrollView>
</RelativeLayout>

But other activities are regular. This happened when I was trying to fix the keyboard covering EditText issue. However I almost solved that, new one raised.

For fixing it, I added scroll view in the above relative layout.

The manifest part of the activity is as follows

<activity
android:name=".OfferRide"
android:label="@string/title_activity_offer_ride"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan|stateAlwaysVisible"
android:theme="@style/AppTheme.NoActionBar" />

Other activity where things are normal. enter image description here

File: 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>

        <item name="md_positive_color">@color/colorPrimary</item>
        <item name="md_neutral_color">@color/colorPrimary</item>
        <item name="md_title_color">@color/colorPrimary</item>
        <item name="md_negative_color">@color/colorPrimary</item>
        <item name="md_widget_color">@color/colorPrimary</item>
    </style>

    <style name="FullscreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <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>
        <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>
Sibidharan
  • 2,717
  • 2
  • 26
  • 54

4 Answers4

3

In my case, the problem was because I had two files styles.xml in my project, in both of them had the same name of theme for the activities. Let me describe it.

This is my activity in the AndroidManifest.xml:

enter image description here

This is my first styles.xml (default):

enter image description here

This is my second styles.xml (V21):

enter image description here

The app in running mode used the second style, it had the problem, because we couldn't see the colorPrimaryDark of the app.

The solution was, comment the last item in the second style.xml:

enter image description here

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Miguel Rodríguez
  • 2,219
  • 18
  • 13
1

http://developer.android.com/reference/android/support/design/widget/AppBarLayout.html

AppBarLayout is a vertical LinearLayout which implements many of the features of material designs app bar concept, namely scrolling gestures.

Children should provide their desired scrolling behavior through setScrollFlags(int) and the associated layout xml attribute: app:layout_scrollFlags.

This view depends heavily on being used as a direct child within a CoordinatorLayout

Use CoordinatorLayout instead of RelativeLayout and instead of ScrollView, Use NestedScrollView.

And change this:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

to:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

Since you already have Toolbar, let's imagine you've already added this in your OnCreate:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
0

For me, the issue was windowTranslucentStatus:

Before:

<style name="MyTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:colorPrimary">@color/bright_purple</item>
        <item name="android:colorPrimaryDark">@android:color/background_dark</item>
        <item name="android:windowTranslucentStatus">true</item>
</style>

After:

<style name="MyTheme" parent="Theme.AppCompat.NoActionBar">
            <item name="android:colorPrimary">@color/bright_purple</item>
            <item name="android:colorPrimaryDark">@android:color/background_dark</item>
    </style>
Tash Pemhiwa
  • 7,590
  • 4
  • 45
  • 49
-1

Use this in your styles.xml:

<item name="android:statusBarColor">@color/colorPrimaryDarkBlue</item>
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Shiva
  • 454
  • 5
  • 10