recherche

Maison  >  Questions et réponses  >  le corps du texte

Comment Android implémente-t-il la coexistence d’un menu et d’une barre d’état immersive ?

C'est l'effet de la météo Xiaomi


J'ai essayé ça, le menu ne s'affiche pas sous la barre d'état immersive. De la même manière, comment ajouter un menu et l'afficher tout en gardant NoActionBar ?

PHP中文网PHP中文网2829 Il y a quelques jours716

répondre à tous(3)je répondrai

  • 我想大声告诉你

    我想大声告诉你2017-05-27 17:42:01

    Ajoutez un bouton à la mise en page, simple et brut.

    répondre
    0
  • 大家讲道理

    大家讲道理2017-05-27 17:42:01

    0. Référencez le package de support

    1. Définir le thème

    <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. Définir la mise en page

    <?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>
    
    

    3. Mettre en œuvre l'activité

    • Citation du thème et de la mise en page ci-dessus

    • Appelez void setSupportActionBar (barre d'outils de la barre d'outils)void setSupportActionBar (Toolbar toolbar)

    • 定义MenuLayout

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

    Définir la disposition du menu🎜🎜 🎜🎜Remplacez boolean onCreateOptionsMenu (menu Menu) & boolean onPrepareOptionsMenu (menu Menu) & boolean onOptionsItemSelected (élément MenuItem)🎜🎜 🎜

    répondre
    0
  • 大家讲道理

    大家讲道理2017-05-27 17:42:01

    Une ligne de code pour le faire

    répondre
    0
  • Annulerrépondre