本文实例为大家分享了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();
    }
});

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

01-30 23:56
查看更多