HpWens
MeiWidgetView
Java

🔥一款汇总了郭霖,鸿洋,以及自己平时收集的自定义控件集合库(小红书)

Last updated Jun 30, 2026
2.2k
Stars
333
Forks
3
Issues
0
Stars/day
Attention Score
71
Language breakdown
Java 98.7%
Dart 1.3%
Files click to expand
README

Min Sdk Version

最新动态-网页动态背景“五彩蛛网”

在这里插入图片描述在这里插入图片描述

博客地址:Android实现网页动态背景“五彩蛛网”

想了解更多大厂炫酷控件,请关注微信公众号:控件人生

扫一扫 关注我的公众号

不定期的发放现金红包 快到碗里来~

自定义LayoutManager

01 02

博客地址:Android自定义控件进阶篇,自定义LayoutManager

GIF圆角控件

博客地址:探一探,非常实用的GIF图圆角控件(3行代码)

小红书任意拖拽标签控件

在这里插入图片描述在这里插入图片描述

博客地址:Android控件人生第一站,小红书任意拖拽标签控件

小红书自定义CoordinatorLayout联动效果

在这里插入图片描述在这里插入图片描述

博客地址:第一站小红书图片裁剪控件之二,自定义CoordinatorLayout联动效果

小红书图片裁剪控件

在这里插入图片描述在这里插入图片描述

博客地址:第一站小红书图片裁剪控件,深度解析大厂炫酷控件

Flutter“蛛网”控件

博客地址:Flutter自定义控件第一式,炫酷“蛛网”控件

源码地址

MeiWidgetView

一款汇总了郭霖,鸿洋,以及自己平时收集的自定义控件的集合库。主旨帮助大家学习自定义控件中的一些技巧,分析问题解决问题的一种思路。

引入

Step 1. Add the JitPack repository to your build file

root build.gradle


    allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
    }</code></pre>

Step 2. Add the dependency

app build.gradle


	dependencies {
	       implementation &#39;com.github.HpWens:MeiWidgetView:v0.1.6&#39;
	}</code></pre>

Download APK

使用

1、文字路径

a、效果预览

b、xml布局


    &lt;com.meis.widget.MeiTextPathView
        ...
        android:layoutwidth=&quot;matchparent&quot;
        android:layoutheight=&quot;wrapcontent&quot;/&gt;</code></pre>

c、xml属性


    &lt;declare-styleable name=&quot;MeiTextPathView&quot;&gt;
        &lt;!-- 路径文字 --&gt;
        &lt;attr name=&quot;text&quot; format=&quot;string&quot;/&gt;  
	&lt;!-- 路径文字大小 --&gt;
        &lt;attr name=&quot;textSize&quot; format=&quot;dimension&quot;/&gt;
	&lt;!-- 路径文字颜色 --&gt;
        &lt;attr name=&quot;textColor&quot; format=&quot;color&quot;/&gt;
	&lt;!-- 路径绘制时长 --&gt;
        &lt;attr name=&quot;duration&quot; format=&quot;integer&quot;/&gt;
	&lt;!-- 文字的描边宽度 --&gt;
        &lt;attr name=&quot;strokeWidth&quot; format=&quot;dimension&quot;/&gt;
	&lt;!-- 是否循环绘制 --&gt;
        &lt;attr name=&quot;cycle&quot; format=&quot;boolean&quot;/&gt;
	&lt;!-- 是否自动开始播放 --&gt;
        &lt;attr name=&quot;autoStart&quot; format=&quot;boolean&quot;/&gt;
    &lt;/declare-styleable&gt;</code></pre>

d、参考文章

文字路径动画控件TextPathView解析

2、弹跳小球

a、效果预览

b、xml布局


    &lt;com.meis.widget.ball.BounceBallView
        ...
        android:layoutwidth=&quot;matchparent&quot;
        android:layoutheight=&quot;wrapcontent&quot;&gt;</code></pre>

c、属性

  • bounce_count :小球弹跳次数
  • ball_color:小球颜色
  • ball_count:小球数量
  • ball_radius:小球半径
  • ball_delay:小球出现时间间隔(当小球数大于1时)
  • anim_duration:小球一次动画时长
  • physic_mode : 开启物理效果(下落加速上升减速)
  • random_color: 开启小球颜色随机
  • random_radius: 开启小球大小随机(在基础大小上下浮动)
  • random_path: 开启小球路径随机(在基础路径坐标上下浮动)

d、参考文章

自定义View之小球自由落体弹跳加载控件

3、扩散圆(主题切换)

a、效果预览

b、xml布局


    &lt;com.meis.widget.MeiRippleView
        ...
        android:layoutwidth=&quot;matchparent&quot;
        android:layoutheight=&quot;wrapcontent&quot; /&gt;</code></pre>

c、相关方法


    /**
     * @param startX      被点击view相对屏幕的 view中心点x坐标
     * @param startY      被点击view相对屏幕的 view中心点y坐标
     * @param startRadius 开始扩散的半径
     */
    public void startRipple(int startX, int startY, int startRadius)</code></pre>

d、参考文章

Android自定义View实现炫酷的主题切换动画(仿酷安客户端)

4、酷炫的路径

a、效果预览

b、xml布局


    &lt;com.meis.widget.MeiLinePathView
        ...
        android:layoutwidth=&quot;matchparent&quot;
        android:layoutheight=&quot;wrapcontent&quot; /&gt;</code></pre>

c、相关方法


    //设置路径
    public void setPath(Path path) {
        mKeyframes = new Keyframes(path);
        mAlpha = 0;
    }</code></pre>

d、参考文章

Android仿bilibili弹幕聊天室后面的线条动画

5、MEI-图片滚动视差控件

a、效果预览

b、xml布局


    &lt;com.meis.widget.MeiScrollParallaxView
        ...
        android:layoutwidth=&quot;matchparent&quot;
        android:layoutheight=&quot;wrapcontent&quot;/&gt;</code></pre>

c、属性


    &lt;declare-styleable name=&quot;MeiScrollParallaxView&quot;&gt;
        &lt;!-- 滚动速率 (0~1) 值越大滚动视差越明显 --&gt;
        &lt;attr name=&quot;parallaxRate&quot; format=&quot;float&quot;/&gt;
        &lt;!-- 滑动是否显示视差 默认 true --&gt;
        &lt;attr name=&quot;enableParallax&quot; format=&quot;boolean&quot;/&gt;
        &lt;!-- 圆角宽度 默认 0  若通过修改父类来实现 则不需要设置此值--&gt;
        &lt;attr name=&quot;roundWidth&quot; format=&quot;dimension&quot;/&gt;
        &lt;!-- 是否显示圆形 默认 0  若通过修改父类来实现 则不需要设置此值--&gt;
        &lt;attr name=&quot;enableCircle&quot; format=&quot;boolean&quot;&gt;&lt;/attr&gt;
        &lt;!--圆角外的颜色 默认白色  若通过修改父类来实现 则不需要设置此值--&gt;
        &lt;attr name=&quot;outRoundColor&quot; format=&quot;color&quot;/&gt;
    &lt;/declare-styleable&gt;</code></pre>

d、参考文章

打造丝滑的滑动视差控件(ScrollParallaxView)

6、MEI-直播间送爱心

a、效果预览

b、xml布局


    &lt;com.meis.widget.heart.MeiHeartView
        ...
        android:layoutwidth=&quot;matchparent&quot;
        android:layoutheight=&quot;wrapcontent&quot;/&gt;</code></pre>

c、属性


    &lt;declare-styleable name=&quot;MeiHeartView&quot;&gt;
        &lt;!--爱心动画时长--&gt;
        &lt;attr name=&quot;heartDuration&quot; format=&quot;integer&quot;/&gt;
        &lt;!--是否显示透明度动画--&gt;
        &lt;attr name=&quot;heartEnableAlpha&quot; format=&quot;boolean&quot;/&gt;
        &lt;!--是否显示缩放动画--&gt;
        &lt;attr name=&quot;heartEnableScale&quot; format=&quot;boolean&quot;/&gt;
    &lt;/declare-styleable&gt;</code></pre>

d、参考文章

PathMeasure之直播间送爱心

7、Mei-selector控件集

a、效果预览

通过 xml 布局的方式替换掉 selector 文件 , 这么做的优势在于 , 减少 apk 体积 , 避免后期维护大量的 selector 文件 , 扩展性更强 , 易修改 , 直观 , 功能更加强大

b、特性

  • 支持圆角(单独设定四个角角度,圆角半径是高度的一半)
  • 支持背景Pressed,Disabled,Selected,Checked四种状态切换
  • 支持描边(虚线,四种状态切换)
  • 支持文本(四种状态切换)
  • 支持涟漪(水波纹)
  • 支持leftDrawable,topDrawable,rightDrawable,bottomDrawable四种状态切换

c、支持原生控件

  • RadiusTextView
  • RadiusCheckBox
  • RadiusEditText
  • RadiusFrameLayout
  • RadiusLinearLayout
  • RadiusRelativeLayout

d、扩展

委托的扩展方式(Delegate), 参考的是(AppCompatActivity实现方式), 具体请参考(RadiusTextView)

8、MEI-仿百度浏览器图片拖拽控件

a、效果预览

b、xml布局


//PhotoDragRelativeLayout 继承 RelativeLayout 委托的方式 易扩展
&lt;com.meis.widget.photodrag.PhotoDragRelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    android:id=&quot;@+id/pdr_content&quot;
    android:layoutwidth=&quot;matchparent&quot;
    android:layoutheight=&quot;matchparent&quot;
    android:background=&quot;#000&quot;&gt;

&lt;android.support.v7.widget.Toolbar android:id=&quot;@+id/toolbar&quot; android:layoutwidth=&quot;matchparent&quot; android:layoutheight=&quot;wrapcontent&quot; android:background=&quot;@color/colorPrimary&quot; app:navigati app:title=&quot;仿百度浏览器图片拖拽控件&quot; app:titleTextColor=&quot;#FFF&quot; /&gt;

&lt;me.relex.photodraweeview.PhotoDraweeView android:id=&quot;@+id/pdv_photo&quot; android:layoutwidth=&quot;matchparent&quot; android:layoutheight=&quot;matchparent&quot; android:layout_below=&quot;@+id/toolbar&quot; android:src=&quot;@mipmap/icmeiripple&quot; /&gt;

&lt;/com.meis.widget.photodrag.PhotoDragRelativeLayout&gt;</code></pre>

c、相关代码


   mPdrLayout.setDragListener(new PhotoDragHelper().setOnDragListener(new PhotoDragHelper.OnDragListener() {
       @Override
       public void onAlpha(float alpha) {
           //透明度的改变
           mPdrLayout.setAlpha(alpha);
       }
       @Override
       public View getDragView() {
           //返回需要拖拽的view
           return mPdvView;
       }
       @Override
       public void onAnimationEnd(boolean isRestoration) {
           //isRestoration true 执行恢复动画  false 执行结束动画
           if (!isRestoration) {
               finish();
               overridePendingTransition(0, 0);
           }
       }
   }));</code></pre>

9、MEI-仿头条小视频拖拽控件

针对头条效果做了如下优化

  • 列表图片没有完全展示点击的转场动画图片明显变形压缩
  • 详情页往顶部拖拽有明显的卡顿现象

a、效果预览

b、xml布局


&lt;com.meis.widget.photodrag.VideoDragRelativeLayout
    ...
    android:layoutwidth=&quot;matchparent&quot;
    android:layoutheight=&quot;matchparent&quot;/&gt;</code></pre>

c、属性


    &lt;declare-styleable name=&quot;VideoDragRelativeLayout&quot;&gt;

&lt;!-- 统一前缀 mei 当前父控件是否拦截事件 默认true--&gt; &lt;attr name=&quot;meiselfintercept_event&quot; format=&quot;boolean&quot;&gt;&lt;/attr&gt;

&lt;!-- 进入动画时长 默认 400 --&gt; &lt;attr name=&quot;meistartanim_duration&quot; format=&quot;integer&quot;&gt;&lt;/attr&gt;

&lt;!-- 结束动画时长 默认 400 --&gt; &lt;attr name=&quot;meiendanim_duration&quot; format=&quot;integer&quot;&gt;&lt;/attr&gt;

&lt;!-- 恢复系数有关[0~1] 恢复系数越大则需要拖动越大的距离 --&gt; &lt;attr name=&quot;meirestorationratio&quot; format=&quot;float&quot;&gt;&lt;/attr&gt;

&lt;!-- y轴偏移速率 值越大偏移越慢 默认2 --&gt; &lt;attr name=&quot;meioffsetrate_y&quot; format=&quot;integer&quot;&gt;&lt;/attr&gt;

&lt;!-- y轴开始偏移系数 默认0.5 --&gt; &lt;attr name=&quot;meistartoffsetratioy&quot; format=&quot;float&quot;&gt;&lt;/attr&gt;

&lt;!-- 开始动画是否进入 默认true --&gt; &lt;attr name=&quot;meistartanim_enable&quot; format=&quot;boolean&quot;&gt;&lt;/attr&gt;

&lt;/declare-styleable&gt;</code></pre>

VideoDragRelativeLayout 继承 RelativeLayout 默认拦截并消费事件 , 若子控件想消费事件请在 xml 布局文件中设置子控件 android:tag="dispatch"

d、回调接口


    public interface OnVideoDragListener {

//开始拖拽 void onStartDrag();

/** * 释放拖拽 * @param isRestoration 是否恢复 true 则执行恢复动画 false 则执行结束动画 */ void onReleaseDrag(boolean isRestoration);

/** * 动画结束 * @param isRestoration 是否恢复 true 执行的恢复动画结束 false执行的结束动画结束 */ void onCompleteAnimation(boolean isRestoration); }</code></pre>

10、仿膜拜单车贴纸效果

基于jbox2d引擎实现 , 文中有相应的代码注释请查阅

a、效果图

b、xml布局


    &lt;com.meis.widget.mobike.MoBikeView
        android:layout_width=&quot;0dp&quot;
        android:layout_height=&quot;0dp&quot;
	...   
	/&gt;</code></pre>

11、LOVE玫瑰

a、效果预览

b、xml布局


    &lt;com.meis.widget.rose.RoseGiftSurfaceView
        android:id=&quot;@+id/rose&quot;
        android:layout_width=&quot;0dp&quot;
        android:layout_height=&quot;0dp&quot;
        ... /&gt;</code></pre>

c、开始动画


 mRoseGiftSurfaceView.startAnimation();</code></pre>

12、浮动粒子

通过三阶贝塞尔曲线,绘制每个粒子的运动轨迹

请下载apk查看实际效果

b、xml布局


    &lt;com.meis.widget.particle.FireflyView
        android:id=&quot;@+id/firfly&quot;
        android:layout_width=&quot;0dp&quot;
        android:layout_height=&quot;0dp&quot;
        ... /&gt;</code></pre>

c、属性


    &lt;declare-styleable name=&quot;FireflyView&quot;&gt;
        &lt;!-- 浮点粒子数量 默认400 --&gt;
        &lt;attr name=&quot;firefly_num&quot; format=&quot;integer&quot;&gt;&lt;/attr&gt;
        &lt;!-- 浮点粒子的最大半径 默认5 --&gt;
        &lt;attr name=&quot;fireflymaxradius&quot; format=&quot;integer&quot;&gt;&lt;/attr&gt;
        &lt;!-- 浮点粒子的移动速率 默认5 越大移动越慢 --&gt;
        &lt;attr name=&quot;fireflymoverate&quot; format=&quot;integer&quot;&gt;&lt;/attr&gt;
    &lt;/declare-styleable&gt;</code></pre>

13、直播间点赞控件

贝塞尔曲线来计算点赞小图标的位置

b、相关代码


// 初始化
mPraiseAnimator = new BezierPraiseAnimator(this);
// 开始动画
mPraiseAnimator.startAnimation(mIvPraise);</code></pre>

14、文本跳动控件

一款炫酷的文本跳动控件

文章博客地址:一篇文本跳动控件,为你打开一扇大门,学会这两点心得,控件你也会写

15、豆瓣弹性滑动控件

文章博客地址:仿豆瓣弹性滑动控件,史上最全方位讲解事件滑动冲突

Contact

QQ群:478720016

wiki

欢迎发邮件或者提issue

LICENSE


Copyright 2018 文淑

Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</code></pre>

© 2026 GitRepoTrend · HpWens/MeiWidgetView · Updated daily from GitHub