Google provides the seekbar control, which makes it easy to create drawer effects. However, many problems still occur when using the control at first, so the record is as follows:
Two of the attributes are important:
Progressdrawable: Specifies the background color of seekbar. Thumb indicates the sliding image.
Note the following two points:
1. After thumb is set, the sliding image is hidden. Set thumboffset to solve this problem.
android:thumbOffset="0dp"
2. You need to modify the fill color during the sliding seekbar process and create a drawable file,
For example, the specific code named seekbar_style.xml is as follows?
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item android:id="@android:id/background"><shape><corners android:radius="10dip" /><gradient android:startColor="#ffffffff"android:centerColor="#ffffffff" android:endColor="#ffffffff"android:centerY="0.45" android:angle="270" /></shape></item><item android:id="@android:id/progress"><clip><shape><corners android:radius="10dip" /><gradient android:startColor="#FF75BC32"android:centerColor="#FF75BC32" android:endColor="#FF75BC32"android:centerY="0.45" android:angle="270" /></shape></clip></item></layer-list>
Background sets the Default background color of seekbar, and Progress sets the filled color during the sliding process.
4. Set the slider width and set maxheight and minheight to the same value, as shown in figure
android:maxHeight="4dp" android:minHeight="4dp"
The complete seekbar style code is as follows:
<SeekBar android:layout_marginLeft="25dp" android:thumb="@drawable/progress_bar_button" android:layout_width="327dp" android:layout_height="18dp" android:thumbOffset="0dp" android:maxHeight="4dp" android:minHeight="4dp" android:progressDrawable="@drawable/seekbar_style" android:id="@+id/seekBarVolume"></SeekBar>
As follows:
Imagebutton:
setImageBitmap(Bitmap bm) setImageDrawable(Drawable drawable) setImageResource(int resId)
You can set a transparent background by setting background.
Android: Background = "#00000000"
Translucent
Android: Background = "#7f000000.