Use of Android seekbar

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.