• DiscreteSeekBar使用简介,一个带气泡的SeekBar


    android自带的SeekBar样式比较古板,如果我们想让自己的SeekBar炫起来,那么可以考虑使用DiscreteSeekBar。DiscreteSeekBar是GitHub上的一个开源控件,地址https://github.com/AnderWeb/discreteSeekBar,那么我们今天就来看看DiscreteSeekBar的使用。

    先来看一张效果图:

    上面那个红色的SeekBar就是android自带的SeekBar,下面的是DiscreteSeekBar,当我们拖动的时候,上面会有一个气泡实时显示当前值,我们一起来看看怎么做。

    最近刚刚开始使用Android Studio,感觉还不错,所以这个Demo就用As来做了,我们首先要在build.gradle中添加依赖:

    compile 'org.adw.library:discrete-seekbar:1.0.0'
    下面我们看看上面这个东西的布局文件:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 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:orientation="vertical"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin">
    
        <SeekBar
            android:id="@+id/seekb2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="100dp"
            android:max="100" />
    
        <org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
            android:id="@+id/seekb1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:dsb_indicatorColor="#05f75e"
            app:dsb_indicatorFormatter="百分之%03d"
            app:dsb_indicatorTextAppearance="?android:attr/textAppearanceSmall"
            app:dsb_progressColor="#999999"
            app:dsb_max="100"
            app:dsb_min="0"
            app:dsb_trackColor="#440be2"
            app:dsb_mirrorForRtl="false"
            app:dsb_rippleColor="#fc1307"
            app:dsb_value="20" />
    </LinearLayout>
    第一个SeekBar就是系统自带的SeekBar,第二个就是我们要说的DiscreteSeekBar,我们看看这里每个属性的含义:


    dsb_indicatorColor表示气泡的颜色
    dsb_progressColor表示SeekBar的颜色
    dsb_trackColor表示进度条中那一条细线的颜色
    dsb_rippleColor表示手指滑动地方的颜色

    dsb_indicatorFormatter表示气泡中文字的显示格式,比如:

    app:dsb_indicatorFormatter="百分之%03d"
    会显示出“百分之XXX”,%d表示显示数值,0后面的3表示数字显示的位数

    dsb_indicatorTextAppearance表示气泡中文本的显示样式

    app:dsb_max="100"
    app:dsb_min="0" 这两个分别表示DiscreteSeekBar的最大值和最小值

    dsb_value表示DiscreteSeekBar的当前值...。

    当然,上面这些属性我们也可以在Java代码中进行设置。

    Demo下载http://download.csdn.net/detail/u012702547/9306151

       
    
  • 相关阅读:
    微信小程序开发之选项卡
    sublime text3安装cssrem 插件步骤
    我的第二个Vue项目
    node下载指定版本
    我的第一个vue项目构建
    js实现二级月日联动菜单
    webStrom设置打开默认浏览器
    html-webpack-plugin Configuration配置信息
    webpack html-webpack-plugin 遍历
    git使用笔记
  • 原文地址:https://www.cnblogs.com/lenve/p/5865923.html
Copyright © 2020-2023  润新知