BubbleSeekBar
A beautiful Android custom seekbar, which has a bubble view with progress appearing upon when seeking. 自定义SeekBar,进度变化更以可视化气泡样式呈现
Top Related Projects
:octocat:💧 A slider widget with a popup bubble displaying the precise value selected. Swift UI library made by @Ramotion
A beautiful and powerful SeekBar what supports single、 range、steps、vetical、custom( 一款美观强大的支持单向、双向范围选择、分步、垂直、高度自定义的SeekBar)
Quick Overview
BubbleSeekBar is a custom Android SeekBar library that provides a bubble-like indicator to show the current progress. It offers a visually appealing and interactive way for users to select values within a range, with the added benefit of displaying the current value in a floating bubble above the seek bar.
Pros
- Customizable appearance with various attributes for colors, sizes, and shapes
- Smooth animations for the bubble indicator
- Supports both continuous and discrete (sectioned) modes
- Compatible with both Java and Kotlin Android projects
Cons
- Limited to Android platform only
- May require additional effort to integrate with existing UI frameworks
- Documentation is primarily in Chinese, which might be challenging for non-Chinese speakers
Code Examples
- Basic implementation:
<com.xw.repo.BubbleSeekBar
android:id="@+id/bubbleSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_max="100"
app:bsb_min="0"
app:bsb_progress="50" />
- Customizing appearance:
<com.xw.repo.BubbleSeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_bubble_color="#FF6F00"
app:bsb_bubble_text_color="#FFFFFF"
app:bsb_track_color="#CCCCCC"
app:bsb_second_track_color="#FF6F00"
app:bsb_thumb_color="#FF6F00" />
- Using discrete mode:
<com.xw.repo.BubbleSeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_max="5"
app:bsb_min="1"
app:bsb_section_count="4"
app:bsb_show_section_mark="true"
app:bsb_show_section_text="true" />
Getting Started
- Add the dependency to your app's
build.gradle
file:
dependencies {
implementation 'com.xw.repo:bubbleseekbar:3.20'
}
- Add the BubbleSeekBar to your layout XML:
<com.xw.repo.BubbleSeekBar
android:id="@+id/bubbleSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_max="100"
app:bsb_min="0"
app:bsb_progress="50" />
- In your Activity or Fragment, you can interact with the BubbleSeekBar:
val bubbleSeekBar: BubbleSeekBar = findViewById(R.id.bubbleSeekBar)
bubbleSeekBar.setOnProgressChangedListener(object : BubbleSeekBar.OnProgressChangedListener {
override fun onProgressChanged(bubbleSeekBar: BubbleSeekBar, progress: Int, progressFloat: Float, fromUser: Boolean) {
// Handle progress change
}
override fun getProgressOnActionUp(bubbleSeekBar: BubbleSeekBar, progress: Int, progressFloat: Float) {
// Handle progress when user releases touch
}
override fun getProgressOnFinally(bubbleSeekBar: BubbleSeekBar, progress: Int, progressFloat: Float, fromUser: Boolean) {
// Final progress value
}
})
Competitor Comparisons
:octocat:💧 A slider widget with a popup bubble displaying the precise value selected. Swift UI library made by @Ramotion
Pros of fluid-slider
- Offers a more visually appealing and modern design with fluid animations
- Provides a unique "bubble" indicator that displays the current value
- Supports both iOS and Android platforms
Cons of fluid-slider
- Limited customization options compared to BubbleSeekBar
- May have a steeper learning curve due to its more complex implementation
- Requires additional setup for custom styling and behavior
Code Comparison
BubbleSeekBar:
<com.xw.repo.BubbleSeekBar
android:id="@+id/bubbleSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_max="100"
app:bsb_min="0"
app:bsb_progress="50" />
fluid-slider:
val slider = FluidSlider(context)
slider.positionListener = { pos -> Log.d("fluid-slider", "Current value: ${slider.position * 100}") }
slider.beginTrackingListener = { /* Handle tracking start */ }
slider.endTrackingListener = { /* Handle tracking end */ }
Both libraries offer unique slider implementations, with BubbleSeekBar focusing on customization and ease of use, while fluid-slider emphasizes visual appeal and modern design. The choice between them depends on the specific requirements of your project and the desired user experience.
Pros of discreteSeekBar
- Offers discrete steps, allowing for more precise value selection
- Provides a material design-inspired look and feel
- Supports both horizontal and vertical orientations
Cons of discreteSeekBar
- Less visually appealing bubble indicator compared to BubbleSeekBar
- Limited customization options for the bubble appearance
- Lacks some advanced features like section text and custom thumb drawable
Code Comparison
BubbleSeekBar:
<com.xw.repo.BubbleSeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_bubble_color="#FF6E40"
app:bsb_bubble_text_color="@color/colorPrimary"
app:bsb_max="100"
app:bsb_min="0"
app:bsb_progress="50" />
discreteSeekBar:
<org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:dsb_min="0"
app:dsb_max="100"
app:dsb_value="50" />
Both libraries offer custom SeekBar implementations, but BubbleSeekBar provides more extensive customization options and a more visually appealing bubble indicator. discreteSeekBar, on the other hand, focuses on providing discrete steps and a material design look. The choice between the two depends on specific project requirements and design preferences.
A beautiful and powerful SeekBar what supports single、 range、steps、vetical、custom( 一款美观强大的支持单向、双向范围选择、分 步、垂直、高度自定义的SeekBar)
Pros of RangeSeekBar
- Supports dual thumb (range) selection, allowing users to select a range of values
- Offers more customization options, including thumb size, track height, and tick marks
- Provides smoother animation and touch feedback
Cons of RangeSeekBar
- Lacks the bubble indicator feature present in BubbleSeekBar
- May have a steeper learning curve due to more configuration options
- Less frequent updates and maintenance compared to BubbleSeekBar
Code Comparison
BubbleSeekBar:
mBubbleSeekBar = findViewById(R.id.bubbleSeekBar);
mBubbleSeekBar.setProgress(50);
mBubbleSeekBar.setOnProgressChangedListener(new BubbleSeekBar.OnProgressChangedListener() {
@Override
public void onProgressChanged(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat, boolean fromUser) {
// Handle progress change
}
});
RangeSeekBar:
RangeSeekBar rangeSeekBar = findViewById(R.id.rangeSeekBar);
rangeSeekBar.setRange(0, 100);
rangeSeekBar.setValue(20, 80);
rangeSeekBar.setOnRangeChangedListener(new OnRangeChangedListener() {
@Override
public void onRangeChanged(RangeSeekBar view, float leftValue, float rightValue, boolean isFromUser) {
// Handle range change
}
});
Both libraries offer easy-to-use APIs for implementing seekbars in Android applications. RangeSeekBar provides more flexibility with its range selection feature, while BubbleSeekBar offers a unique bubble indicator for better visual feedback. The choice between the two depends on specific project requirements and desired user experience.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
A beautiful Android custom seek bar, which has a bubble view with progress appearing upon when seeking. Highly customizable, mostly demands has been considered. star
or pull request
will be welcomed
Screenshot
Download
dependencies {
// lite version (recommended)
// e.g. implementation 'com.xw.repo:bubbleseekbar:3.20-lite'
implementation 'com.xw.repo:bubbleseekbar:${LATEST_VERSION}-lite'
// enhanced version
// e.g. 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();
Check out the demo for more details. Or download the apk: sample.apk
Attentions
-
There are two versions of this library.The differences as follow:
version init getter/setter lite xml min, max, progress enhanced xml, java all attrs lite version is recommended.
-
You must correct the offsets by setting
ScrollListener
whenBubbleSeekBar
's parent view is scrollable (such asScrollView
, exceptViewPager
), otherwise, the appearing position of the bubble may be wrong. For example:
mContainer.setOnYourContainerScrollListener(new OnYourContainerScrollListener() {
@Override
public void onScroll() {
// call this method to correct offsets
mBubbleSeekBar.correctOffsetWhenContainerOnScrolling();
}
});
- When customize the section texts, you should make sure that the attr
bsb_section_text_position
has been set tobelow_section_mark
at first, then follow the example below in your java code:
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;
}
});
BTW, the attr bsb_show_thumb_text
will be set to false
automatically for avoiding the text coverage display problems.
- The attr
bsb_always_show_bubble
is not supported in theRecyclerView
,ListView
andGridView
.
Attributes
How to submit a valid issue
- Make sure you compiled the latest version. If it still doesn't work out, don't hesitate to open a new issue.
- Describe the scenarios or operates when crash happened as much as possible(pictures would be better).
- Tell me your device type and Android OS version is very helpful.
- Paste your xml or java code.
- Paste the crash log.
- Please be polite.
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.
Top Related Projects
:octocat:💧 A slider widget with a popup bubble displaying the precise value selected. Swift UI library made by @Ramotion
A beautiful and powerful SeekBar what supports single、 range、steps、vetical、custom( 一款美观强大的支持单向、双向范围选择、分步、垂直、高度自定义的SeekBar)
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot