Skip to content

fendoudebb/DragBadgeView

Repository files navigation

DragBadgeView

仿QQ可拖拽控件

博客地址:http:https://blog.csdn.net/fendoudebb/article/details/76146252

样例演示

引入

添加依赖

dependencies {
	compile 'com.fendoudebb.view:dragbadgeview:1.0.3'
}

xml配置

<com.fendoudebb.view.DragBadgeView
        android:id="@+id/drag_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="30dp"
        android:paddingBottom="2dp"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:paddingTop="2dp"
        app:dragEnable="false"
        app:maxShowValue="99"
        app:text="0"
        app:textSize="18sp"/>

回调

mDragBadgeView.setOnDragBadgeViewListener(new DragBadgeView.OnDragBadgeViewListener() {
    @Override
    public void onDisappear(String text) {
        Toast.makeText(getApplicationContext(), text + "条信息隐藏!", Toast.LENGTH_SHORT).show();
    }
});

设置文字

app:text="测试"
mDragBadgeView.setText("测试");

获取文字

public String getStringText();

public int getIntText();

设置字体大小

app:textSize="12sp"
mDragBadgeView.setTextSize(dp2sp(15));

设置控件颜色

app:bgColor="#f0f"
mDragBadgeView.setBgColor(Color.BLUE);

设置能否拖拽

app:dragEnable="false"
mDragBadgeView.setDragEnable(true);