0

I read many SO topics and other tutorials, but I did not get answer for this question:

What is right way to stylize(customize) standard SeekBar ? (a namely: set size(height) and color to progress line and thumb)

I found two way to realize this:

  1. Create .png(or .9.png) for progress line and thumb and use it.
  2. Create .xml in drawable. In .xml create layer-list, in layer-list item-shape.

__

One people says, use first way, other says - use second way.

What the right way? Might have a good third way?

__

I try second way, but can not understand, how can I specify my size(height) for progress and secondary progress. How can I do this?

What I want:

enter image description here

My SeekBar:

<SeekBar
        android:layout_width="306dp"
        android:layout_height="wrap_content"
        android:progressDrawable="@drawable/seek_bar_progress"
        android:thumb="@drawable/seek_bar_thumb"/>

seek_bar_progress.xml:

<?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 android:shape="rectangle">
        <solid android:color="#FFFFFF" />
    </shape>
</item>
<item android:id="@android:id/secondaryProgress">
    <shape android:shape="rectangle">
        <solid android:color="#FFFFFF" />
    </shape>
</item>
<item android:id="@android:id/progress">
    <shape android:shape="rectangle">
        <solid android:color="#0000FF" />
    </shape>
</item>
</layer-list>

seek_bar_thumb.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item >
        <shape android:shape="oval">
            <solid android:color="#0000FF"/>
            <size android:height="31dp" android:width="31dp"/>
        </shape>
    </item>
</layer-list>
researcher
  • 1,758
  • 22
  • 25
  • The third way is to get an instance of your view (e.g. seekbar, progressbar, etc) in your java code and set it's size (width, height) property. http://stackoverflow.com/questions/13509989/how-to-set-the-android-progressbars-height/27301074#27301074 – Martin Pfeffer Dec 12 '15 at 23:30
  • @MartinPfeffer, thank you for response! But this not what I need. – researcher Dec 13 '15 at 11:08

0 Answers0