Android刘海屏适配库NotchFit简介及使用方式

NotchFit

智能刘海屏适配库

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

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

引入方式

compile 'com.wcl.notchfit:notchfit:1.3'

使用方式

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.黑条填充

name

 NotchFit.fitUnUse(this);

更多使用方式请查看github NotchFit

此库若有bug,欢迎指出,多谢多谢!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值