Reverse seekbar (Right to left) colour

拈花ヽ惹草 提交于 2019-12-13 13:30:31

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/16231609/reverse-seekbar-right-to-left-colour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!