for reason, status bar white. or rather, off white, shade of white icons faintly visible against bright background. wrong, because appbarlayout uses blue shade color. until now, has been working fine, don't know did cause this. i've tried manually setting statusbarcolor colorprimarydark (#0277bd), it's not working.
i don't know why happening in first place. i'm pasting activity's layout.xml, maybe can clue me in i'm doing wrong here.
a few notes:
the themes used haven't been changed defaults, use primary color settings. changed right shade of blue wanted, when did change working.
my layout.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:statusbarcolor="@color/colorprimarydark" tools:context=".activities.contactsactivity"> <android.support.design.widget.appbarlayout android:id="@+id/contactsactivityappbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitssystemwindows="true" android:statusbarcolor="@color/colorprimarydark" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/contactsactivitytoolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" app:popuptheme="@style/apptheme.popupoverlay"/> <!-- app:layout_scrollflags="scroll|enteralways" --> <android.support.design.widget.tablayout android:id="@+id/contactsactivitytabs" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabindicatorcolor="@android:color/white" android:scrollbarstyle="insideoverlay" android:paddingbottom="1dp" android:background="@color/colorprimary"/> </android.support.design.widget.appbarlayout> <android.support.v4.view.viewpager android:id="@+id/contactstabsviewpager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"/> </android.support.design.widget.coordinatorlayout>
colors.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorprimary">#0288d1</color> <color name="colorprimarydark">#0277bd</color> <color name="coloraccent">#ff4081</color> </resources>
styles.xml
<resources> <!-- base application theme. --> <style name="apptheme" parent="theme.appcompat.light.darkactionbar"> <!-- customize 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>
edit: ok, found interesting solution, want understand it, not rely on it. also, might not best answer long term.
anyway, base application theme (apptheme) in styles.xml, added following line:
<item name="android:windowbackground">@color/colorprimarydark</item>
it worked, made background of didn't assign color color. made status bar color, went through , added own backgrounds other things fix them.
i feel isn't ideal solution, though, , more feedback in general. also, without line before, coloring status bar fine. have no idea did break in first place.
thanks.
edit: here activity code. thanks.
import android.content.intent; import android.os.bundle; import android.support.design.widget.tablayout; import android.support.v4.view.viewpager; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.menu; import android.view.menuitem; import io.craigmiller160.contacts5.r; import io.craigmiller160.contacts5.fragments.contactsgroupsfragmentpage; import io.craigmiller160.contacts5.fragments.contactslistfragmentpage; import io.craigmiller160.contacts5.fragments.contactstabspageradapter; public class contactsactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_contacts); toolbar toolbar = (toolbar) findviewbyid(r.id.contactsactivitytoolbar); setsupportactionbar(toolbar); viewpager viewpager = (viewpager) findviewbyid(r.id.contactstabsviewpager); contactstabspageradapter adapter = new contactstabspageradapter(getsupportfragmentmanager()); adapter.addfragmentpage(new contactslistfragmentpage(), "contacts"); adapter.addfragmentpage(new contactsgroupsfragmentpage(), "groups"); viewpager.setadapter(adapter); tablayout tablayout = (tablayout) findviewbyid(r.id.contactsactivitytabs); tablayout.setupwithviewpager(viewpager); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); //noinspection simplifiableifstatement if (id == r.id.displaysettings) { intent intent = new intent(this, displaysettingsactivity.class); startactivity(intent); return true; } return super.onoptionsitemselected(item); } }
<item name="android:statusbarcolor">@android:color/transparent</item>
you'll see line of code in values/styles/styles.xml(v21)
. remove , solves issue
Comments
Post a Comment