简体   繁体   中英

Android SeekBar [ProgressBar] style - how to set custom background drawable

I want to make seekbar like this: http://img687.imageshack.us/img687/2371/volumec.png The thing is, that I ve already found customizing seekbars over here http://groups.google.com/group/android-developers/browse _thread/thread/be3fed0b4f766cc?pli=1 but the problem is, that I need **those gaps** between in my drawable and I don t know how to manage that. Would you be so kind some of you, I`ll appreciate it very much. Thanks in advance, wishing all the best!

this is my resources style.xml file that is applied to seekbar:

<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/seekbarcolors</item>
<item name="android:indeterminateDrawable">@drawable/seekbarcolors</item>
<item name="android:minHeight">20dip</item>
<item name="android:maxHeight">20dip</item>
<item name="android:thumbOffset">8px</item>
<item name="android:focusable">true</item>

and here is my @drawable/seekbarcolors:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
    <shape>
        <solid android:color="#ff0000" />
    </shape>
</item>
<item android:id="@android:id/secondaryProgress">
    <clip>
        <shape>
            <solid android:color="#00ff00" />
        </shape>
    </clip>
</item>
<item android:id="@android:id/progress">
    <clip>
        <shape>
            <solid android:color="#0000ff" />
        </shape>
    </clip>
</item>

A Seekbar is a pretty powerful widget. Ddo you want the user to be able to "seek" the volume here? It's not made to show progress with gaps.

What you need here (if you don't need to grab and seek the volume) is lots simpler. Create a single ImageView to the right of "Volume" in your sample pic. In your progress-watching AsyncTask, put code in onProgressUpdate() to change the shown image across 10 images - each the same as the last but with one more bar - as progress breaks each 10%. You can write code to put a single image times properly positioned across a space, but that is harder and buys you little.

要在android中更改音量条颜色,请在framework / core / res / res / layout中更改volume_adjust.xml中的颜色

The thing is that i need to seek volume..as you can see, i' ve styled seekbar with my custom shape where colors are set Last thing i need to do is create repeatable shape with block of opacity 1 and block with opacity 0. How this can be done? I am new to android developmemt therefore not very smart with shapes :) thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM