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>
mDragView = findViewById(R.id.drag);
mDragView.onClickListener(new DragView.OnClickListener() {
@Override
public void onClick() {
Toast.makeText(activity,"Touch",Toast.LENGTH_SHORT).show();
}
});