小編這次要給大家分享的是詳解Android自定義view如何實現拖拽選擇按鈕,文章內容豐富,感興趣的小伙伴可以來了解一下,希望大家閱讀完這篇文章之后能夠有所收獲。
本文實例為大家分享了Android實現拖拽選擇按鈕的具體代碼,供大家參考,具體內容如下
github地址:https://github.com/xuezj/DragChooseDemo
DragChooseDemo
效果圖

Attributes屬性(布局文件中的自定義屬性)

半徑、文字大小、按鈕個數注意配合使用,以達到最佳效果
方法

使用
布局文件中的使用
<com.xuezj.dragchooselibrary.view.DragChooseView android:id="@+id/my_view" android:layout_width="wrap_content" android:layout_height="wrap_content" choose:background_color="#efeff4" choose:border_color="#ffcfcfd3" choose:enabled="@mipmap/sliderwifion" choose:focused="@mipmap/sliderwifioff" choose:text_size="12sp" choose:counts="5" choose:radius="20" />
代碼中調用
dragChooseView =(DragChooseView)findViewById(R.id.my_view);
dragChooseView.setTextData("自定義","單選","雙選","全選","sss","ddd");
dragChooseView.addOnChooseItemListener(new DragChooseView.OnChooseItemListener() {
@Override
public void chooseItem(int index, String text) {
Toast.makeText(MainActivity.this, text, Toast.LENGTH_SHORT).show();
}
});看完這篇關于詳解Android自定義view如何實現拖拽選擇按鈕的文章,如果覺得文章內容寫得不錯的話,可以把它分享出去給更多人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。