How to modify the SeekBar style in Android

Source: Internet
Author: User

SeekBar configuration file:
Xml Code Copy codeThe Code is as follows: <SeekBar
Android: id = "@ + id/player_seekbar"
Android: layout_width = "245px"
Android: layout_height = "25px"
Android: progressDrawable = "@ drawable/seekbar_style"
Android: thumb = "@ drawable/thumb"
Android: paddingLeft = "16px"
Android: paddingRight = "15px"
Android: paddingTop = "5px"
Android: paddingBottom = "5px"
Android: progress = "0"
Android: max = "0"
Android: secondaryProgress = "0"
/>

Android: progressDrawable = "@ drawable/seekbar_style" Background
Seekbar_style is configured as follows:
Xml CodeCopy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>

<Layer-list xmlns: android = "http://schemas.android.com/apk/res/android">

<Item android: id = "@ android: id/background">
<Shape>
<Corners android: radius = "5dip"/>
<Gradient
Android: startColor = "# ff9d9e9d"
Android: centerColor = "# ff5a5d5a"
Android: centery= "0.75"
Android: endColor = "# ff747674"
Android: Angular = "270"
/>
</Shape>
</Item>

<Item android: id = "@ android: id/secondaryProgress">
<Clip>
<Shape>
<Corners android: radius = "5dip"/>
<Gradient
Android: startColor = "#80ffd300"
Android: centerColor = "#80ffb600"
Android: centery= "0.75"
Android: endColor = "# a0ffcb00"
Android: Angular = "270"
/>
</Shape>
</Clip>
</Item>

<Item android: id = "@ android: id/progress">
<Clip>
<Shape>
<Corners android: radius = "5dip"/>
<Gradient
Android: startColor = "# ff0099CC"
Android: centerColor = "# ff3399CC"
Android: centery= "0.75"
Android: endColor = "# ff6699CC"
Android: Angular = "270"
/>
</Shape>
</Clip>
</Item>

</Layer-list>

Or, use the following image:
Xml CodeCopy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<Layer-list xmlns: android = "http://schemas.android.com/apk/res/android">

<Item android: id = "@ android: id/background"
Android: drawable = "@ drawable/progress_bg"/>

<Item android: id = "@ android: id/secondaryProgress"
Android: drawable = "@ drawable/second_progress">
</Item>

<Item android: id = "@ android: id/progress"
Android: drawable = "@ drawable/first_progress">

</Item>
</Layer-list>

Square
Xml CodeCopy codeThe Code is as follows: <layer-list xmlns: android = "http://schemas.android.com/apk/res/android">
<Item android: id = "@ android: id/background"
Android: drawable = "@ drawable/progress_bg"/>
<Item android: id = "@ android: id/secondaryProgress">
<Clip android: drawable = "@ drawable/second_progress"/>
</Item>
<Item android: id = "@ android: id/progress">
<Clip android: drawable = "@ drawable/first_progress"/>
</Item>
</Layer-list>

Android: thumb = "@ drawable/thumb" is the moving ball.
The configuration is as follows:
Xml CodeCopy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<Selector xmlns: android = "http://schemas.android.com/apk/res/android">

<! -- Press status -->
<Item
Android: state_focused = "true"
Android: state_pressed = "true"
Android: drawable = "@ drawable/thumb_pressed"/>
<! -- Normal no-focus status -->
<Item
Android: state_focused = "false"
Android: state_pressed = "false"
Android: drawable = "@ drawable/thumb_normal"/>
<! -- With Focus -->
<Item
Android: state_focused = "true"
Android: state_pressed = "false"
Android: drawable = "@ drawable/thumb_focused"/>
<! -- Focus -->
<Item
Android: state_focused = "true"
Android: drawable = "@ drawable/thumb_focused"/>
</Selector>

Related Article

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.