仿小红书的图片标签

TagViewGroup

项目地址: shellljx/TagViewGroup
简介:仿小红书的图片标签
更多: 作者    提 Bug    示例 APK   
标签:
图片标签- 小红书- 自定义ViewGroup-

Android 仿小红书图片标签,实现了图片标签的动画,布局,水波纹,编辑等功能,还可以自定义 Tag。视频演示地址

This is a library of tags that are attached to the picture,you can add tags and ripple effects very easily.Video demo

Important Update

  1. added TagAdapter and make it easier to create TagViewGroup.

  2. moved AnimatorUtils out of the library to make it clean.

Gradle

Step 1. 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.shellljx:TagViewGroup:-SNAPSHOT'
}

How to use

1. Define in xml

<com.licrafter.tagview.TagViewGroup
    android:id="@+id/tagViewGroup"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:inner_radius="4dp"
    app:line_width="1dp"
    app:radius="8dp"
    app:ripple_alpha="100"
    app:ripple_radius="20dp"
    app:tilt_distance="20dp"/>

2. Or in code

TagViewGroup tagViewGroup = new TagViewGroup(getContext());

3. Add animator

// set hide animator ,show animator and ripple
tagViewGroup.setHideAnimator(hideAnimator).setShowAnimator(showAnimator).addRipple();

4. Set tagAdapter

tagViewGroup.setTagAdapter(new TagAdapter() {
    @Override
    public int getCount() {
        return model.getTags().size();
    }

    @Override
    public ITagView getItem(int position) {
        return makeTagTextView(model.getTags().get(position));
    }
});

//set tagViewGroup location
tagViewGroup.setPercent(model.getPercentX(), model.getPercentY());

5. NotifyDataSetChanged

tagViewGroup.getTagAdapter().notifyDataSetChanged();

6. Handle click events

tagViewGroup.setOnTagGroupClickListener(new TagViewGroup.OnTagGroupClickListener() {
    @Override
    public void onCircleClick(TagViewGroup container) {
    //click the white circle of TagViewGroup         
    }

    @Override
    public void onTagClick(TagViewGroup container, ITagView tag, int position) {
    //clikc a tag of TagViewGroup
    }

    @Override
    public void onLongPress(TagViewGroup container) {

    }
});

7. Drag TagViewGroup

//you can drag tagViewGroup only if you set OnTagGroupDragListener
tagViewGroup.setOnTagGroupDragListener(new TagViewGroup.OnTagGroupDragListener() {
    @Override
    public void onDrag(TagViewGroup container, float percentX, float percentY) {

    }
});

Attributes:

attr 属性description 描述
inner_radius中心内圆半径
radius中心外圆半径
line_width线条宽度
v_distance圆心到垂直折点的垂直距离
tilt_distance圆心到斜线折点的垂直距离
ripple_alpha水波纹起始透明度
ripple_maxRadius水波纹最大半径

How to customize the animation

You can use the following properties in Property Animation:

property 属性description 描述
LinesRatio(TagViewGroup.LINES_RATIO)线条显现的长度占总长度的百分比
TagAlpha(TagViewGroup.TAG_ALPHA)单个 Tag 的透明度
CircleRadius(TagViewGroup.CIRCLE_RADIUS)中心圆半径
CircleInnerRadius(TagViewGroup.CIRCLE_INNER_RADIUS)中心内圆半径

How to implement your own Tag view

Step 1. create a view implement ITagView interface.

Step 2. Override the following methods:

@Override
public void setDirection(DIRECTION direction) {
    mDirection = direction;
}

@Override
public DIRECTION getDirection() {
    return mDirection;
}
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
小红书”——给你安利几个小程序的“坑”微信小程序写在前面  小程序发布至今已有一年多时间,很多人都已经在小程序道路上狂奔。最近我也开始了学习小程序,学了一段时间后,想看看这段时间的学习效果,于是边学习边开始了我的第一个小程序。相信很多人都用过小红书吧,我可是被它安利了很多好东西呢,所以想着就仿写一个小红书的微信小程序吧。下面我就给大家“安利”几个我在写的过程中的“坑”。  因为花的时间不多,功能有很多没有完善,页面写的不是很好看,请各位将就着看啦。╮(╯▽╰)╭   准备工作  1. 开发环境:WXML(HTML),WXSS(CSS),Javascript  2. 开发工具:vscode,微信开发者工具  3. 辅助工具:Markman:图标标注工具,可用于取色、测量。Easy-Mock:可以伪造假数据,在js中引用就好了。点这里可以查看我的项目数据。Markdown:在线编辑器GifCam:Gif录制工具 微信小程序开发文档Iconfont-阿里巴巴矢量图标库:各种需要的小图标都有哦遇到的几个问题1、首页导航栏左右滑动效果图:  这部分,是通过微信小程序的scroll-view组件来完成的。代码如下:<scroll-view class="navBar-box" scroll-x="true"  一些使用scroll-view的注意事项:请勿在 scroll-view 中使用 textarea、map、canvas、video 组件scroll-into-view 的优先级高于 scroll-top在滚动 scroll-view 时会阻止页面回弹,所以在 scroll-view 中滚动,是无法触发 onPullDownRefresh若要使用下拉刷新,请使用页面的滚动,而不是 scroll-view ,这样也能通过点击顶部状态栏回到页面顶部2、首页文章列表随着点击导航栏列表改变效果图:  这部分,是通过微信小程序的swiper组件来完成的。代码如下:                                                                                                    {{notes.title}}                              <!-- 作者信息 -->                                              {{notes.writer}}                                                {{notes.like}}                                    使用swiper组件,将所有文章列表包起来,每个swiper-item表示不同的列表模块。之前在导航栏各列表项绑定了不同
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值