项目作者: 2hamed

项目描述 :
Android library mimicing the iOS's volume and light vertical sliders
高级语言: Kotlin
项目地址: git://github.com/2hamed/VerticalSlider.git
创建时间: 2019-03-04T18:02:11Z
项目社区:https://github.com/2hamed/VerticalSlider

开源协议:

下载


Vertical Slider for Android

Download
Android Arsenal

Have you ever seen those sleek volume and light sliders for iOS? Well here they are for Android as an extremely lightweight library.

Showcase

It allows to set 3 different icons for different states of the slide: low, medium and high.

Usage

As always it is available through jCenter:

  1. implementation 'com.hmomeni.verticalslider:verticalslider:0.2.0'

There are a number of properties which can be set either in xml or code:

Icons

You can set icons directly by setting Bitmap values to them or you can use any of the helper methods to pass in a Resource Id:

  1. iconHigh: Bitmap
  2. iconMedium: Bitmap
  3. iconLow: Bitmap
  4. verticalSlider.setIconHighResourse(R.drawable.ic_volume_high)
  5. verticalSlider.setIconMediumResourse(R.drawable.ic_volume_medium)
  6. verticalSlider.setIconLowResourse(R.drawable.ic_volume_low)

Max & Progress

max can be any integer larger than 0 and progress should be: 0 <= progress <= max

  1. max: Int // the maximum amount that the slider will allow
  2. progress: Int // the current progress of slider

Other properties

  1. verticalSlider.cornerRadius = dpToPx(10).toFloat()
  2. // this gets called in every update of the progress
  3. verticalSlider.onProgressChangeListener = object : VerticalSlider.OnSliderProgressChangeListener {
  4. override fun onChanged(progress: Int, max: Int) {
  5. // use progress and max to calculate percentage
  6. }
  7. }
  1. <com.hmomeni.verticalslider.VerticalSlider
  2. android:id="@+id/verticalSlider"
  3. android:layout_width="120dp"
  4. android:layout_height="250dp"
  5. app:vs_cornerRadius="10dp"
  6. app:vs_iconHigh="@drawable/volume_high"
  7. app:vs_iconLow="@drawable/volume_low"
  8. app:vs_iconMedium="@drawable/volume_medium"
  9. app:vs_max="100"
  10. app:vs_progress="10" ></com.hmomeni.verticalslider.VerticalSlider>

Feel free to post any issues or feature requests.