廢話不多說,先給效果圖
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIiZpdmL1cTM2IDOwkTM5IjNwkTMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.gif)
使用
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.SineyCoder:DragPhoto:1.0'
}
<com.siney.lib.dragphoto.DragFrameLayout
android:id="@+id/drag_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:gap="5dp"
app:placeholder="@android:drawable/ic_input_add">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="後續布局"/>
</com.siney.lib.dragphoto.DragFrameLayout>
DragFrameLayout layout = findViewById(R.id.drag_layout);
layout.setListener(this);//添加監聽,有4個不同的回調,
分别是1.placeholder圖檔加載完成 2.圖檔點選事件 3.圖檔是否可拖拽(return false表示不可拖拽) 4.圖檔是否允許交換(return false表示不可交換)
注意
//裡面的每一個圖檔都是DragImage,裡面有num以及path,在設定圖檔時請使用下列進行設定,内部使用Glide進行圖檔渲染
image.setImage(path, type);
有問題歡迎來我github網站提問,謝謝大家支援!~