雙向選擇玲销;
支持氣泡功能输拇,氣泡文字,背景樣式可以自定義贤斜;
進(jìn)度條按鈕策吠,顏色,寬度在xml中設(shè)置瘩绒;
「GitHub地址」用的上的話猴抹,點(diǎn)star不迷路,小老弟跪求了~
樣式
使用
Grade
allprojects {
repositories {
...
maven { url 'https://www.jitpack.io' }
}
}
dependencies {
implementation 'com.github.yujinzhao123:DoubleHeadedDragonBar:1.0.4'
}
Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://www.jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.yujinzhao123</groupId>
<artifactId>DoubleHeadedDragonBar</artifactId>
<version>1.0.4</version>
</dependency>
屬性
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="DoubleHeadedDragonBar">
<!--進(jìn)度條按鈕寬高-->
<attr name="button_width" format="dimension" />
<attr name="button_height" format="dimension" />
<!--進(jìn)圖條按鈕圖片-->
<attr name="button_img" format="reference"/>
<!--單位字體顏色-->
<attr name="text_color" format="color"/>
<!--進(jìn)圖條背景顏色-->
<attr name="bg_color" format="color"/>
<!--進(jìn)度條顏色-->
<attr name="value_color" format="color"/>
<!--進(jìn)度條寬-->
<attr name="seek_height" format="dimension"/>
</declare-styleable>
</resources>
案layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
tools:context=".MainActivity">
<cn.bar.DoubleHeadedDragonBar
android:layout_margin="10dp"
android:id="@+id/bar"
app:text_color="#5C6980"
app:button_img="@drawable/button"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<cn.bar.DoubleHeadedDragonBar
android:layout_below="@+id/bar"
android:layout_margin="10dp"
android:id="@+id/bar1"
app:text_color="#1B97F7"
app:button_img="@mipmap/seek_button"
app:button_height="40dp"
app:button_width="40dp"
app:bg_color="#999"
app:value_color="#e97051"
app:seek_height="6dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
Activity
final int maxValue = 6;
bar = findViewById(R.id.bar);
//設(shè)置單位刻度顯示
bar.setUnit("0公斤", "6公斤");
bar.setCallBack(new DoubleHeadedDragonBar.DhdBarCallBack() {
//返回氣泡顯示文字
@Override
public String getMinMaxString(int value, int value1) {
return value + "~" + value1;
}
//結(jié)束觸摸 按百分比返回選擇值锁荔,范圍 0~100
@Override
public void onEndTouch(float minPercentage, float maxPercentage) {
}
});
//設(shè)置氣泡按鈕
testView2 = (TextView) LayoutInflater.from(this).inflate(R.layout.toast_view, null);
bar.setToastView2(testView2);
testView = (TextView) LayoutInflater.from(this).inflate(R.layout.toast_view, null);
bar.setToastView(testView);
testView.setText("0");
testView1 = (TextView) LayoutInflater.from(this).inflate(R.layout.toast_view, null);
bar.setToastView1(testView1);
testView1.setText("6");
bar1 = findViewById(R.id.bar1);
bar1.setUnit("0", "100");
bar1.setMinValue(10);
bar1.setMaxValue(80);
}