可以显示浮动文字提示的ProgressBar或者SeekBar
jopen
9年前
可以显示浮动文字提示的ProgressBar或者SeekBar。
运行效果:
使用说明:
1) build.gradle:
repositories { jcenter() maven { url "https://jitpack.io" } } dependencies { compile 'com.github.techery.progresshint:library-addition:{jitpack-release}' }
2) XML
<io.techery.progresshint.addition.widget.SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" app:popupStyle="follow" />
或者
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper android:layout_width="wrap_content" android:layout_height="match_parent" > <io.techery.progresshint.addition.widget.VerticalSeekBar android:layout_width="0dp" android:layout_height="0dp" app:seekBarRotation="CW90" app:popupStyle="follow" app:popupLayout="@layout/custom_seekbar_hint_popup" app:popupAlwaysShown="true" /> <!-- Rotation: CW90 or CW270 --> </com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper>
可用的属性:
popupLayout: layout to be used, must include android:id/text1 TextView popupStyle: can be fixed or follow, default follow popupAnimationStyle: in/out animation, default fade popupOffset: distance from top/right of the widget to popup, default 0 popupAlwaysShown: do not dismiss popup after onStopTrackingTouch, default false popupDraggable: enables progress change by hint popup dragging, default true
3) 在java代码中自定义显示的文字(可选):
SeekBarHintDelegateHolder seekBar = (SeekBarHintDelegateHolder) findViewById(R.id.seekBar); seekBar.getHintDelegate() .setHintAdapter(new SeekBarHintAdapter() { @Override public String getHint(android.widget.SeekBar seekBar, int progress) { return "Progress: " + String.valueOf(progress); } });
4) 使用Theme属性(可选):
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="progressHintStyle">@style/Widget.ProgressHint</item> </style>