项目
在 GitHub 查看
woxingxiao/BubbleSeekBar
关于
一款精美的 Android 自定义 SeekBar,拖动时会显示带进度的气泡视图。自定义 SeekBar,以可视化气泡的形式呈现进度变化。
其他项目实测星标增长
- 24小时
- 0
- 7天
- -2
- 15天
- -4
- 1个月
- -8
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README_zh.md
原文
自定义SeekBar,进度变化由可视化气泡样式呈现,定制化程度较高,适合大部分需求。欢迎star or pull request
Screenshot


Download
dependencies {
// lite version 轻量版(推荐)
// 例如:implementation 'com.xw.repo:bubbleseekbar:3.20-lite'
implementation 'com.xw.repo:bubbleseekbar:${LATEST_VERSION}-lite'
// enhanced version 增强版
// 例如:implementation 'com.xw.repo:bubbleseekbar:3.20'
// implementation 'com.xw.repo:bubbleseekbar:${LATEST_VERSION}'
}
Usage
Init in xml
<com.xw.repo.BubbleSeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_bubble_color="@color/color_red_light"
app:bsb_bubble_text_color="@color/colorPrimaryDark"
app:bsb_max="50.0"
app:bsb_min="-50"
app:bsb_progress="0"
app:bsb_second_track_color="@color/color_red"
app:bsb_section_count="5"
app:bsb_section_text_position="bottom_sides"
app:bsb_show_progress_in_float="true"
app:bsb_show_section_mark="true"
app:bsb_show_section_text="true"
app:bsb_show_thumb_text="true"
app:bsb_track_color="@color/color_red_light"/>
<com.xw.repo.BubbleSeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_auto_adjust_section_mark="true"
app:bsb_second_track_color="@color/color_blue"
app:bsb_section_count="5"
app:bsb_section_text_position="below_section_mark"
app:bsb_show_section_mark="true"
app:bsb_show_section_text="true"
app:bsb_show_thumb_text="true"
app:bsb_thumb_text_size="18sp"
app:bsb_touch_to_seek="true"/>
Init in java (not for lite version)
mBbubbleSeekBar.getConfigBuilder()
.min(0.0)
.max(50)
.progress(20)
.sectionCount(5)
.trackColor(ContextCompat.getColor(getContext(), R.color.color_gray))
.secondTrackColor(ContextCompat.getColor(getContext(), R.color.color_blue))
.thumbColor(ContextCompat.getColor(getContext(), R.color.color_blue))
.showSectionText()
.sectionTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary))
.sectionTextSize(18)
.showThumbText()
.thumbTextColor(ContextCompat.getColor(getContext(), R.color.color_red))
.thumbTextSize(18)
.bubbleColor(ContextCompat.getColor(getContext(), R.color.color_green))
.bubbleTextSize(18)
.showSectionMark()
.seekBySection()
.autoAdjustSectionMark()
.sectionTextPosition(BubbleSeekBar.TextPosition.BELOW_SECTION_MARK)
.build();
查看demo获知更多使用细节。或者下载安装apk:sample.apk
Attentions
下列是两个版本的差异对比:
version init getter/setter lite xml min, max, progress enhanced xml, java all attrs 推荐使用 lite 版本。
如果
BubbleSeekBar的外部容器是可滑动的控件(如:ScrollView,但ViewPager除外),需要设置滑动监听来修正气泡的偏移, 否则滑动后气泡出现位置可能错乱。方法如下:
mContainer.setOnYourContainerScrollListener(new OnYourContainerScrollListener() {
@Override
public void onScroll() {
// 调用修正偏移方法
mBubbleSeekBar.correctOffsetWhenContainerOnScrolling();
}
});
- 当自定义section texts的时候,你首先需要确保属性
bsb_section_text_position已经被设置为below_section_mark, 然后在java代码中参照以下代码实现你自己的需求:
mBubbleSeekBar.setCustomSectionTextArray(new BubbleSeekBar.CustomSectionTextArray() {
@NonNull
@Override
public SparseArray<String> onCustomize(int sectionCount, @NonNull SparseArray<String> array) {
array.clear();
array.put(1, "bad");
array.put(4, "ok");
array.put(7, "good");
array.put(9, "great");
return array;
}
});
顺便,为了防止文字覆盖显示问题,属性bsb_show_thumb_text将被自动置false。
- 属性
bsb_always_show_bubble在RecyclerView,ListView和GridView中不被支持。
Attributes
怎样提出有效的issue
- 确保你使用的是最新版本。 如果仍然有问题,请开新issue;
- 尽可能详细的描述crash发生时的使用场景或者操作(有图片说明更好);
- 告知手机型号和系统版本;
- 贴出你的xml或者java代码;
- 贴出你的奔溃日志;
- 礼貌。
人生苦短,请选择科学上网。无限流量,节点多速度快。电梯直达
License
Copyright 2017 woxingxiao
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
探索相关项目
加载中…