Skip to content

xiong955/DragView

Repository files navigation

DragView

Download
一个类似IOS小圆点的可拖动控件

使用方式

implementation 'com.xiong.widget:dragview:1.0.3'

属性相关

animationTime 动画时间
backgroundColor 背景颜色
foregroundImage 前景图
bounce 是否开启反弹动画
welt 是否贴边
dragWidth 拖动控件的宽
dragHeight 拖动控件的高
marginLeft 控件居左距离
marginRight 控件居右距离(不能同时设置marginLeft,否则该属性无效)
marginTop 控件居顶距离
marginBottom 控件居底距离(不能同时设置marginTop,否则该属性无效)

布局文件

<FrameLayout>

    //可拖动区域的布局
    <LinearLayout...>

    <com.xiong.DragView
        android:id="@+id/drag"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:animationTime="200"
        app:backgroundColor="#f9f035"
        app:bounce="true"
        app:dragHeight="60"
        app:dragWidth="60"
        app:marginRight="100"
        app:marginTop="100"
        app:foregroundImage="@mipmap/ic_launcher"
        app:welt="true" />

</FrameLayout>

Java代码

mDragView = findViewById(R.id.drag);
mDragView.onClickListener(new DragView.OnClickListener() {
    @Override
    public void onClick() {
        Toast.makeText(activity,"Touch",Toast.LENGTH_SHORT).show();
    }
});

效果如图:
贴边 回弹 时间
使用中遇到什么问题请issues反馈
或者QQ联系我:619291607,备注Git