How to make Statusbar not transparent(Android 5) -
i'm using coordinatorlayout , this(app:layout_scrollflags="scroll|enteralways"
) line of code in order hide toolbar whenever recyclerview scrolled. , works pretty well, toolbar not hidden behind statusbar because transparent.
my layout looks 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:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:context="com.yannisbecker.backup.mainactivity"> <android.support.design.widget.appbarlayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingtop="@dimen/appbar_padding_top" 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:layout_scrollflags="scroll|enteralways" /> <android.support.design.widget.tablayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" /> </android.support.design.widget.appbarlayout> <android.support.v4.view.viewpager android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"/> <android.support.design.widget.floatingactionbutton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center|bottom" android:layout_margin="@dimen/fab_margin" android:src="@drawable/ic_backup_white_24dp"/> </android.support.design.widget.coordinatorlayout>
since searched internet , found lot of things "how make statusbar transparent" i'm asking here , hope can me.
because don't have enought reputation, yet, can find image shows problem here
if want hide toolbar under status bar when recycler-view scrolled, you've change color of status-bar liking , remove attribute: android:fitssystemwindows="true"
<coordinatorlayout>
tag.
setting color of status bar can done in mainactivity using getwindow.setstatusbarcolor()
method :
if (build.version.sdk_int >= build.version_codes.lollipop) { getwindow().setstatusbarcolor(getresources().getcolor(r.color.primary_dark)); }
or
add or edit, if present, tag in styles.xml file in apptheme.noactionbar
style
<item name="android:statusbarcolor">@android:color/color_of_your_choice</item>
Comments
Post a Comment