国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

java - Android如何實現菜單和沉浸式狀態欄共存?

瀏覽:116日期:2023-11-21 15:44:42

問題描述

這是小米天氣的效果

java - Android如何實現菜單和沉浸式狀態欄共存?我嘗試過這個,在沉浸式狀態欄下是不顯示菜單的。類似這個,如何在保持NoActionBar的情況下,加入菜單并且顯示出來呢?

問題解答

回答1:

布局上加個按鈕,簡單粗暴。

回答2:0.引用Support包1.定義Theme

<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>2.定義Layout

<?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.AppBarLayoutxmlns:appCompat='http://schemas.android.com/apk/res-auto'android: android:layout_width='match_parent'android:layout_height='wrap_content'android:theme='?actionBarTheme'><android.support.v7.widget.Toolbar android: 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>3.實現Activity

引用上述Theme & Layout

調用 void setSupportActionBar (Toolbar toolbar)

定義MenuLayout

重寫boolean onCreateOptionsMenu (Menu menu) & boolean onPrepareOptionsMenu (Menu menu) & boolean onOptionsItemSelected (MenuItem item)

回答3:

一行代碼搞定

標簽: java
相關文章:
主站蜘蛛池模板: 石阡县| 祁连县| 左权县| 龙里县| 北辰区| 平顺县| 竹北市| 白沙| 新兴县| 方城县| 庄浪县| 上蔡县| 石林| 康平县| 鄯善县| 封丘县| 华蓥市| 苏尼特右旗| 祁连县| 江永县| 乌什县| 南康市| 安徽省| 乌拉特中旗| 句容市| 如皋市| 台东市| 临高县| 甘德县| 长白| 巩义市| 富蕴县| 华坪县| 乐陵市| 定西市| 宣威市| 江油市| 海丰县| 定远县| 余庆县| 江源县|