Anirudh
Anirudh

Reputation: 2090

Reverse seekbar (Right to left) colour

I've been trying to implement a seek bar similar to the ones you use to accept or decline a call.

For call accept I set sbLeft.setProgress(0) and for call decline I set sbRight.setProgress(15), with setMax=15 bot both seek bars. This gives me half of the desired result.

The problem I face is with the colours.

As I drag the left seekbar to accept a call I need a green colour that covers the dragged part. For that I use the following code (giving me the desired result):

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


<item android:id="@android:id/background"> 
    <shape> 
        <corners android:radius="5dip" /> 


        <solid android:color="@android:color/transparent"/>
    </shape> 
</item> 

<item android:id="@android:id/secondaryProgress"> 
    <clip> 
        <shape> 
            <corners android:radius="5dip" /> 
          <!--   
            <gradient 
                android:startColor="#41a317" 
                android:centerColor="#4cc417" 
                android:centerY="0.75" 
                android:endColor="#347c17" 
                android:angle="270"  />-->
                <solid android:color="@android:color/transparent"/>
        </shape>
    </clip> 
</item> 

<item android:id="@android:id/progress"> 
    <clip> 
        <shape> 
            <corners android:radius="5dip" /> 

            <gradient 
                android:startColor="#41a317" 
                android:centerColor="#4cc417" 
                android:centerY="0.75" 
                android:endColor="#347c17" 
                android:angle="270"  />

        </shape> 
    </clip> 
</item> 

</layer-list> 

However this doesnt work for the call decline, even though I switch the transparent colour tags and the gradient tags.

PS: I realize my question might be a little confusing. Hope Ive tried my best to explain my problem.

Upvotes: 4

Views: 5587

Answers (1)

VSB
VSB

Reputation: 10385

Here you can find code for customizing a SeekBar in order to make it Rigth to Left.
Android SeekBar Flipped Horizontally
I hope that it can help u to wonder what you are looking for.

Upvotes: 3

Related Questions