Android开源库-用于显示标签的流式布局

来源:互联网 发布:死亡天使蘑菇 淘宝 编辑:程序博客网 时间:2024/06/18 14:22

Android开源库-用于显示标签的流式布局

Label

流式布局,封装用于显示标签

效果图:

使用方式:

1.添加布局

    <com.brioal.labelview.LabelView        android:id="@+id/main_label"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:background="#213f"        />

2.代码设置:

//设置点击事件 mLabelView.setListener(new OnLabelSelectedListener() {            @Override            public void selected(int position, String content) {                Toast.makeText(MainActivity.this, content, Toast.LENGTH_SHORT).show();            }        });        mList = new ArrayList<>();        //设置显示数据源        mList.add(new LabelEntity("对方的", "的钱我的我"));        mList.add(new LabelEntity("打扫打扫", "的钱我的我"));        mList.add(new LabelEntity("打扫打扫", "的钱我的我"));        mList.add(new LabelEntity("打扫打扫打扫打扫", "的钱我的我"));        mList.add(new LabelEntity("连骗带哄", "的钱我的我"));        mList.add(new LabelEntity("连骗带哄", "的钱我的我"));        //设置标签背景颜色        mLabelView.setLabelColor(Color.RED);        mLabelView.setLabels(mList);

添加依赖的方法

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 {            compile 'com.github.Brioal:Label:1.0'    }

完成

0 0
原创粉丝点击