美文网首页android
基本UI组件的封装库(三)——basicUI

基本UI组件的封装库(三)——basicUI

作者: Peakmain | 来源:发表于2020-03-18 14:29 被阅读0次

以下是我的基本UI组件该系列的文章,欢迎大家转载和分享:
基本UI组件的封装库(一)——basicUI
基本UI组件的封装库(二)——basicUI
基本UI组件的封装库——basicUI的demo的编写

前言

  • 我在之前BasicUI项目一共包括了:1、Recycleview的封装,支持单布局和多布局,支持添加头部和底部,还包括了悬浮列表的基本封装。2、dialog的封装。支持从底部弹出,并可设置动画,是否宽度全屏等样式。3、NavigationBar的封装,可以在activity中动态设置添加头部。4、PopupWindow的封装 5、editText的封装,自带清除按钮,并设置按钮的颜色和按钮的资源 6、TextView的封装、支持设置背景颜色和背景的圆角大小,以及支持设置文字上下左右的图标居中,7、流式布局的封装(支持刷新数据)、8、仿今日头条的TableLayout、9、花束加载loading效果、10、仿58同城多条目菜单删选封装

  • 这次新增内容有:loading三个:视察动画,仿钉钉的loading,仿老版58同城加载的loading,自定义支付密码键盘,九宫格解锁

  • 修复了navigationbar使用的时候只支持垂直的linearlayout的问题
  • 如果大家有什么问题,欢迎您在下方留言或者在BasicUI中留下的问题

Gradle依赖

  • Step 1. Add the JitPack repository to your build file
    Add it in your root build.gradle at the end of repositories:
    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
  • Step 2. Add the dependency
    dependencies {
            implementation 'com.github.Peakmain:BasicUI:0.0.4'
    }

使用

loading效果


loading的效果.gif
视察动画的loading,布局中直接使用
    <com.peakmain.ui.loading.InspectLoadingView
        android:id="@+id/inspect_loading_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

activity中需要调用show方法来显示

  mInspectLoadingView.show();

隐藏只需要调用hide方法

mInspectLoadingView.hide();
仿钉钉的loading
    <com.peakmain.ui.loading.RotatingLoadingView
        android:id="@+id/rotating_loading_view"
        android:onClick="click"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

默认设置的是全屏展示,如果想以loading的方式显示,可以调用show方法

        RotatingLoadingView rotatingLoadingView = new RotatingLoadingView(this);
        rotatingLoadingView.show();

隐藏还是hide方法

mLoadingView.hide();
仿58同城加载loading
<com.peakmain.ui.loading.ShapeLoadingView
       android:id="@+id/shape_loading_view"
       android:onClick="click"
       android:layout_width="match_parent"
       android:layout_height="match_parent"/>

默认也是全屏,如果想以loading显示,可以使用show方法

    ShapeLoadingView shapeLoadingView = new ShapeLoadingView(this);
    shapeLoadingView.show();
自定义支付密码键盘
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:id="@+id/view_root"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:orientation="vertical">

  <com.peakmain.ui.widget.password.PasswordEditText
      android:id="@+id/password_edit_text"
      android:layout_width="match_parent"
      android:layout_marginTop="@dimen/space_20"
      android:layout_marginLeft="@dimen/space_50"
      android:layout_marginRight="@dimen/space_50"
      android:layout_height="30dp" />

  <com.peakmain.ui.widget.password.CustomerKeyboard
      android:id="@+id/custom_key_board"
      android:layout_width="match_parent"
      android:layout_alignParentBottom="true"
      android:layout_height="wrap_content" />
</RelativeLayout>
  • PasswordEditText的相关方法:
    setPasswordCompleteListener表示设置完成
    addPasswordNumber表示添加号码
    deletePassWord表示删除号码
  • CustomerKeyboard
    CustomerKeyboardClickListener设置监听事件
   mCustomerKeyboard.setOnCustomerKeyboardClickListener(new CustomerKeyboard.CustomerKeyboardClickListener() {
            @Override
            public void click(String number) {
                mEditText.addPasswordNumber(number);
            }

            @Override
            public void delete() {
                 mEditText.deletePassWord();
            }
        });
        mEditText.setPasswordCompleteListener(ToastUtils::showShort);
自定义支付密码键盘.gif
九宫格解锁
    <com.peakmain.ui.widget.lock.LockScreenView
        android:id="@+id/lock_pattern"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

LockScreenView中有个setOnLockSuccessListener方法其中有两个方法,getLockResult表示返回你想判断的结果的字符串,onLockSuccess表示密码正确后的回掉


九宫格解锁.gif

相关文章

网友评论

    本文标题:基本UI组件的封装库(三)——basicUI

    本文链接:https://www.haomeiwen.com/subject/puvqyhtx.html