(尊重原创,转载请说明来处,谢谢)
最近做了一个背景是各种颜色的SeekBar,SeekBar颜色是渐变的,开始颜色、结尾颜色、以及按钮的中间和边框颜色都是可以自定义的,效果图如下:
首先我要讲解一下使用方式,第一、第三个ColorSeekBar是我用函数setColor()设置的颜色,第二个ColorSeekBar的颜色是默认的,大家请看使用代码:
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.lei.brightnessseekbar.MainActivity">
<com.lei.brightnessseekbar.ColorSeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginTop="30dp"/>
<com.lei.brightnessseekbar.ColorSeekBar
android:id="@+id/seekBar2"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginTop="30dp"/>
<com.lei.brightnessseekbar.ColorSeekBar
android:id="@+id/seekBar3"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginTop="30dp"/>
</LinearLayout>
JAVA:
package com.lei.brightnessseekbar;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.B