This is the effect of Xiaomi weather
I tried this, but the menu is not displayed in the immersive status bar. Similar to this, how to add a menu and display it while keeping NoActionBar?
认证高级PHP讲师
Add a button to the layout, simple and crude.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="android:windowContentOverlay">@null</item> <item name="windowActionBar">false</item> <item name="android:windowActionBar">?attr/windowActionBar</item> <item name="windowNoTitle">true</item> <item name="android:windowNoTitle">?attr/windowNoTitle</item> <!-- 状态栏颜色 --> <item name="colorPrimaryDark">#??????</item> <!--<item name="android:statusBarColor">@android:color/transparent</item>--> <!--<item name="android:windowTranslucentStatus">true</item>--> <item name="android:windowTranslucentNavigation">true</item> </style>
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout xmlns:appCompat="http://schemas.android.com/apk/res-auto" android:id="@+id/appBarLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="?actionBarTheme"> <android.support.v7.widget.Toolbar android:id="@+id/ab_toolbar" style="?attr/actionBarStyle" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" appCompat:contentInsetEnd="@dimen/margin" appCompat:contentInsetStart="0dp" appCompat:contentInsetStartWithNavigation="0dp" appCompat:layout_collapseMode="none" appCompat:popupTheme="?attr/actionBarPopupTheme"> <!-- YOUR LAYOUT --> </android.support.v7.widget.Toolbar> </android.support.design.widget.AppBarLayout> <!-- YOUR LAYOUT --> </FrameLayout>
Quoting the above Theme & Layout
Call void setSupportActionBar (Toolbar toolbar)
void setSupportActionBar (Toolbar toolbar)
Define MenuLayout
Rewriteboolean onCreateOptionsMenu (Menu menu) & boolean onPrepareOptionsMenu (Menu menu) & boolean onOptionsItemSelected (MenuItem item)
boolean onCreateOptionsMenu (Menu menu)
boolean onPrepareOptionsMenu (Menu menu)
boolean onOptionsItemSelected (MenuItem item)
One line of code to get it done
Add a button to the layout, simple and crude.
0. Reference the Support package
1. Define Theme
2. Define Layout
3. Implement Activity
Quoting the above Theme & Layout
Call
void setSupportActionBar (Toolbar toolbar)
Define MenuLayout
Rewrite
boolean onCreateOptionsMenu (Menu menu)
&boolean onPrepareOptionsMenu (Menu menu)
&boolean onOptionsItemSelected (MenuItem item)
One line of code to get it done