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

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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值