Skip to content

Commit

Permalink
ADD:BarsHelper添加沉浸式导航栏
Browse files Browse the repository at this point in the history
  • Loading branch information
minminaya committed Apr 24, 2018
1 parent 36ede1c commit 28453c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aau/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 26
versionCode 5
versionName "1.0.4"
versionCode 6
versionName "1.0.5"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
18 changes: 18 additions & 0 deletions aau/src/main/java/com/minminaya/aau/utils/BarsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.FontRes;
Expand Down Expand Up @@ -248,6 +249,23 @@ public static void hideNavigationBar(Activity activity) {
decorView.setSystemUiVisibility(options);
}

/**
* 设置导航栏是否可见,效果表现为,透明背景沉浸式导航栏,上滑不会顶开内容
*
* @param activity activity
* @param isVisible {@code true}: 可见<br>{@code false}: 不可见
*/
public void setNavBarVisibility(final Activity activity, boolean isVisible) {
if (isVisible) {
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
} else {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
View decorView = activity.getWindow().getDecorView();
int visibility = decorView.getSystemUiVisibility();
decorView.setSystemUiVisibility(visibility & ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}

/**
* 显示导航栏
*/
Expand Down

0 comments on commit 28453c3

Please sign in to comment.