android - Activity-based action bar/status bar visibility -


i trying set action bars , status bar within app, have run issue. did have working, wasn't clean way of doing things, decided start over.

on launch activity want status bar visible, pink background i'm using throughout app (no action bar). on next view want both action bar , status bar.

this have within launch activity:

<?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:paddingbottom="8dp"     android:paddingleft="8dp"     android:paddingright="8dp"     android:paddingtop="8dp"     tools:context="com.andrewnwalker.mousetimes_california.parkselectactivity">      <linearlayout         ...>          <textview             .../>          <textview             .../>          <button             .../>          <button             .../>     </linearlayout> </android.support.design.widget.coordinatorlayout> 

and have in second activity:

<?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:fitssystemwindows="true"     tools:context="com.andrewnwalker.mousetimes_california.mainactivity">      <android.support.v7.widget.actionbarcontainer         android:id="@+id/toolbar"         android:layout_width="match_parent"         android:layout_height="?attr/actionbarsize"         android:background="?attr/colorprimary" />      <include layout="@layout/content_main"/> </android.support.design.widget.coordinatorlayout> 

and in content main:

<?xml version="1.0" encoding="utf-8"?> <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"     tools:context="com.andrewnwalker.mousetimes_california.mainactivity"     tools:showin="@layout/activity_main">      <android.support.v4.widget.swiperefreshlayout         ...>          <android.support.v7.widget.recyclerview             ..../>     </android.support.v4.widget.swiperefreshlayout> </relativelayout> 

and in styles:

<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>     <item name="android:typeface">serif</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" /> 

it's bit of mess, i'm pretty confused settings styles , action bars. can suggest changes can make i'm looking for?

at moment first activity has shows status bar text, no background colour, , second activity shows status bar , action bar, contains menu item, don't want.

thanks!

the status bar color conforming material design driven app's theme. can read official docs this, there's not enough information here know sure what's going on. might overriding app theme on first activity in manifest or changing somehow in activity. first activity have peculiar layout. there's no need use coordinatorlayout here if don't have action bar. if need scroll inner linearlayout, use scrollview instead.

to remove action bar menu, make sure you're not returning menu in oncreateoptionsmenu or modifying in onprepareoptionsmenu. remove methods if they're not needed.


Comments