GithubHelp home page GithubHelp logo

systemuivisibilitydemo's Introduction

SystemUIVisibilityDemo

该工程演示了 Android 中正确处理绘制系统状态栏和系统导航栏区域的方式。

涉及的概念

SystemUiVisibility

通过 View.setSystemUiVisibility() 设置状态栏、导航栏及布局相关状态,相关参数:

  • View.SYSTEM_UI_FLAG_FULLSCREEN:隐藏状态栏
  • View.SYSTEM_UI_FLAG_HIDE_NAVIGATION:隐藏导航栏
  • View.SYSTEM_UI_FLAG_LAYOUT_STABLE:当使用 View.SYSTEM_UI_FLAG_FULLSCREENView.SYSTEM_UI_FLAG_HIDE_NAVIGATION 导致状态栏或导航栏显示状态发生变化时,不会触发布局刷新
  • View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN:应用布局时使用状态栏区域
  • View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION:应用布局时使用导航栏区域

fitsSystemWindows

设置控件是否处理 WindowInsets,当值为 true 时,控件默认通过增加 padding 值处理 WindowInsets。 AndroidSdk < 20 可以通过重写 View.fitSystemWindows(Rect) 自定义 WindowInsets 的处理方式,AndroidSdk >= 20 可以通过重写 View.onApplyWindowInsets(WindowInsets)或设置 View.OnApplyWindowInsetsListener 达到同样的效果。

主题样式

  • v19:
    • <item name="android:windowTranslucentStatus">true</item>:设置状态栏为半透明
    • <item name="android:windowTranslucentNavigation">true</item>:设置导航栏为半透明
  • v21:
    • <item name="android:statusBarColor">@android:color/transparent</item>:设置状态栏为透明
    • <item name="android:navigationBarColor">@android:color/transparent</item>:设置导航栏为透明
  • v28:
    • <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>:设置应用可以利用”刘海屏“的”刘海“区域

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.