GithubHelp home page GithubHelp logo

notchfit's Introduction

NotchFit 智能刘海屏适配库

优点:使用简单,刘海参数智能判断,一键式刘海参数回调,无需考虑机型和系统版本差异,适配O版本和P及以上版本。

刘海屏存在于系统O版本、P版本及以上版本,由于google P版本刘海api推出较晚,导致O版本刘海屏的不同厂商的机型有各自不同的 适配方式,再者不同手机系统刘海区域使用设置也有所不同,有的默认开启,有的默认关闭,导致刘海屏适配比较繁琐和复杂,此库 处理了以上所有的问题,并智能判断刘海区域的使用方式和刘海参数的获取,给开发者更好的刘海适配体验!

引入方式

Gradle
repositories {
    jcenter()
}
compile 'com.wcl.notchfit:notchfit:1.4.2'

使用方式

1.沉浸适配

name

  NotchFit.fit(this, NotchScreenType.TRANSLUCENT, new OnNotchCallBack() {
        @Override
        public void onNotchReady(NotchProperty notchProperty) {
            if(notchProperty.isNotchEnable()){
                ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) listParent.getLayoutParams();
                marginLayoutParams.topMargin = notchProperty.getNotchHeight();
                listParent.requestLayout();
            }
        }
   });

2.全屏适配

name

  NotchFit.fit(this, NotchScreenType.FULL_SCREEN, new OnNotchCallBack() {
              @Override
              public void onNotchReady(NotchProperty notchProperty) {
                  if(notchProperty.isNotchEnable()){
                      ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) listParent.getLayoutParams();
                      marginLayoutParams.topMargin = notchProperty.getNotchHeight();
                      listParent.requestLayout();
                  }
              }
          });

3.黑条填充

应用场景:不想对app中的具体全屏UI做针对性刘海适配,可通过此接口一键黑条填充适配!!!

name

 NotchFit.fitUnUse(this);

4.判断设备是否支持刘海 boolean hasNotch = NotchFit.hasNotch(activity);

更多使用方式请查看demo

notchfit's People

Contributors

wcl9900 avatar tenglong9900 avatar

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.