java 封装库 带ui,基本UI组件的封装库(二)——basicUI

前言

我在之前BasicUI项目一共包括了:1、Recycleview的封装,支持单布局和多布局,支持添加头部和底部,还包括了悬浮列表的基本封装。2、dialog的封装。支持从底部弹出,并可设置动画,是否宽度全屏等样式。3、NavigationBar的封装,可以在activity中动态设置添加头部。4、PopupWindow的封装 5、editText的封装,自带清除按钮,并设置按钮的颜色和按钮的资源 6、TextView的封装、支持设置背景颜色和背景的圆角大小,以及支持设置文字上下左右的图标居中

这次新增内容有:1、流式布局的封装(支持刷新数据)、2、仿今日头条的TableLayout、3、花束加载loading效果、4、仿58同城多条目菜单删选封装

如果大家有什么问题,欢迎您在下方留言或者在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.3'

}

使用

关于流式布局的使用

大家直接在布局中引用即可

android:layout_width="match_parent"

android:layout_height="wrap_content"/>

在activity中直接设置adapter即可

BaseFlowAdapter adapter=new BaseFlowAdapter() {

@Override

public int getCount() {

return mCount;//自己数据的实体类的大小

}

@Override

public View getView(final int position, ViewGroup parent) {

return view;//自己的view

}

}

mFlowLayout.setAdapter(adapter);

如果想刷新数据只需要调用自己封装的adapter的notifyDataChange方法即可

adapter.notifyDataChange();

仿今日头条的TableLayout的使用

效果

522944570e1e

效果图.gif

使用:

第一步:自定义自己的TableLayout继承BaseTabLayout将泛型换成自己的实体类就可以了

public class TabLayout extends BaseTabLayout {//换成自己的实体类

public TabLayout(Context context) {

super(context);

}

public TabLayout(Context context, AttributeSet attrs) {

super(context, attrs);

}

public TabLayout(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

}

@Override

public String setTableTitle(List bean, int position) {

return bean.get(position).getName();//标题的名字,换成自己的

}

}

第二步:在自己的布局中使用自己定义的布局就可以了

说明:一共有三个属性大家可以设置。1、未选中文字的颜色originColor,2、选中时候的文字颜色changeColor,3、是否显示下划线isShowUnderLine(下划线的颜色和选中的时候的文字颜色一致)

花束加载loading效果

两种方式:1、大家在布局中使用

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

2、直接在activity中使用show的方式显示和hide的方法隐藏

CircleLoadingView loadingView=new CircleLoadingView(this);

loadingView.show();

loadingView.hide();

未设置自定义属性,后期会加入

仿58同城多条目菜单删选封装

效果

522944570e1e

效果

使用

1、第一步:继承BaseListMenuAdapater,需要设置三个参数,第一个设置标题的布局,第二个设置菜单view的布局,第三个设置菜单的内容

public class ListMenuAdapter extends BaseListMenuAdapater {

@Override

public int getTitleLayoutId() {

return R.layout.ui_list_data_screen_tab;//自己标题的布局

}

@Override

protected void setMenuContent(View menuView, final int position) {

//不同菜单的布局参数设置

}

@Override

protected int getMenuLayoutId() {

return R.layout.ui_list_data_screen_menu;//自己菜单的布局

}

}

第二步:布局中引入ListMenuView

android:id="@+id/list_data_screen_view"

android:layout_width="match_parent"

android:layout_height="match_parent"/>

第三步:设置adapter即可,需要将标题集合传进去

mMenuView = findViewById(R.id.list_data_screen_view);

mMenuView.setAdapter(adapter);//自己的适配器

结语

如果大家感兴趣想知道更多的使用,大家可以看我实战项目wanandorid

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值