android 7.1 底部栏不要隐藏后重启显示

本文详细解析了Android系统中导航栏的控制机制,包括如何通过系统属性设置显示或隐藏导航栏,以及在不同设备上导航栏的行为变化。探讨了PhoneWindowManager类中对导航栏的管理,以及SystemUI中PhoneStatusBar类对导航栏的显示和隐藏操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

diff --git a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/PhoneWindowManager.java
index af0f528..80d926a 100755
--- a/PhoneWindowManager.java
+++ b/PhoneWindowManager.java
@@ -162,6 +162,16 @@ import java.io.PrintWriter;
 import java.util.ArrayList;  //add limit
 import java.util.HashSet;
 import java.util.List;
+//liao modify
+//import android.os.SystemProperties;
 /**
  * WindowManagerPolicy implementation for the Android phone UI.  This
@@ -381,6 +391,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     WindowState mNavigationBar = null;
     boolean mHasNavigationBar = false;
        boolean mCanHideNavigationBar = false;   
     boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side?
     int mNavigationBarPosition = NAV_BAR_BOTTOM;
     int[] mNavigationBarHeightForRotationDefault = new int[4];
@@ -1913,14 +1924,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                         mHandler.removeMessages(MSG_REQUEST_TRANSIENT_BARS);
                     }
                 });
+                   //liao
                    mNavBarListener = new NavBarEventListener(context,
                new NavBarEventListener.Callbacks() {
                     @Override
                     public void onRemoveNavBar() {
                         removeNavigationBarLw();                                      
                    }
                    @Override
                    public void onShowNavBar() {
+                                          SystemProperties.set("persist.sys.app.rotation", "show");
                         addNavigationBarLw();
                     }
                 });
@@ -2040,15 +2054,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
 
         // Allow the navigation bar to move on non-square small devices (phones).
         mNavigationBarCanMove = width != height && shortSizeDp < 600;
         // mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
-        mHasNavigationBar = SystemProperties.get("persist.sys.app.rotation", "middle_port").equals("heng"))
+         mHasNavigationBar = true;
         // Allow a system property to override this. Used by the emulator.
         // See also hasNavigationBar().


diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/PhoneStatusBar.java
index 36f525e..af2d25c 100755
--- a/PhoneStatusBar.java
+++ b/PhoneStatusBar.java
@@ -731,6 +731,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
 
         mScreenPinningRequest = new ScreenPinningRequest(mContext);
         mFalsingManager = FalsingManager.getInstance(mContext);
+               //liao add
+               String GetString = SystemProperties.get("persist.sys.app.rotation", "hide");
+               Log.d("mylog", "PhoneStatusBar=========GetString===============" + GetString);
+               if(GetString.equals("hide")){
+                       removeNavigationBar();
+               }
+               
     }
 
     protected void createIconController() {
@@ -5095,8 +5102,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
         mWindowManager.removeView(mNavigationBarView);
         mNavigationBarView = null;
         mIsNavbarShow = false;
-        Toast.makeText(mContext, "The navigation bar can be came out if we slide or click the bottom ! ! !", Toast.LENGTH_SHORT).show()
-    }
+               SystemProperties.set("persist.sys.app.rotation", "hide");
+        
+       }
 
     public void showNavigationBar() {
         // If we have no Navbar view and we should have one, create it

Android 7.1 (API Level 25)及更高版本中,如果你想要隐藏系统默认的导航或应用的底部布局,你可以使用`AppBarLayout`和`CoordinatorLayout`配合` CoordinatorMode.BEHAVIOR_HIDE_ON_SCROLL`行为。以下是基本步骤: 1. 在XML布局文件中,将`AppBarLayout`作为父容器,并包含你的标题和内容区域: ```xml <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_content" android:fitsSystemWindows="true"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/app_bar_layout" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:elevation="0dp" android:theme="@style/AppTheme.AppBarOverlay"> <!-- Your title and other app bar elements --> </com.google.android.material.appbar.AppBarLayout> <androidx.core.widget.NestedScrollView android:id="@+id/nested_scroll_view" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <!-- Your content here --> </androidx.core.widget.NestedScrollView> </androidx.coordinatorlayout.widget.CoordinatorLayout> ``` 2. 添加`app:layout_behavior`属性到`NestedScrollView`,指定为`"appbar_scrolling_view_behavior"`,这会让滚动事件影响`AppBarLayout`的行为。 3. 在主题风格中设置行为模式: ```xml <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar"> <item name="behavior_hideOnScroll">true</item> </style> ``` 当你向上滑动内容时,底部布局会自动隐藏;当内容滑回屏幕顶部时,它又会显示出来。请注意,对于一些定制需求,如自定义动画或特定场景下的行为控制,你可能需要编写额外的代码来调整细节。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不想写代码的农民工

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值