本文實例為大家分享了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(); }});以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。
|
新聞熱點
疑難解答