搜索栏拇指中心不是在起点 [英] seekbar thumb center not at the start point

查看:338
本文介绍了搜索栏拇指中心不是在起点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为我的照片,在搜索栏进度= 0,但在开始point.my code中的搜索栏拇指中心不是:

as my pic,the seekbar progress =0,but the seekbar thumb center not at the start point.my code:

   <SeekBar  android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:progressDrawable="@drawable/seekbar_progress"
                 android:thumb="@drawable/seekbarthumb"
                 android:minHeight="10dip"
                 android:maxHeight="10dip"
                 android:thumbOffset="0px"
                 android:max="100"
                 android:id="@+id/bright_seekbar"
                 android:layout_marginLeft="60dip"/>

seekbar_progress

seekbar_progress

 <?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:angle="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:angle="270" 
            /> 
        </shape> 
    </clip> 
</item> 
<item android:id="@android:id/progress"> 
    <clip> 
        <shape> 
            <corners android:radius="5dip" /> 
            <gradient 
                    android:startColor="#FFD700" 
                    android:centerColor="#FFB90F" 
                    android:centerY="0.75" 
                    android:endColor="#FFA500" 
                    android:angle="270" 
            /> 
        </shape> 
    </clip> 
 </item> 


</layer-list>

seekbarthumb.xml

seekbarthumb.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" 
      android:drawable="@drawable/pressed_button__volume" />
<item android:state_focused="true" 
      android:drawable="@drawable/pressed_button__volume" />
<item
     android:drawable="@drawable/default_button__volume" />     
</selector>

default_button__volume是图片

default_button__volume is image

推荐答案

终于找到了答案,这里的情况是,的android:thumbOffset 不会与在进度条沿着拇指地方二传手,但是,它的的拇指长度它开始的这是中心点,使搜索栏可以在它的开始点调整滑​​块的中心点。因此,如果我们有一个宽度的拇指图片 50 thumbOffset 有为 25 (50/2),使搜索栏将调整的零值在拇指这将使得拇指出现在中间的是完全的像素25
感谢那个男人谁重定向我知道。

finally found the answer, the case here is that android:thumbOffset is NOT a setter for the thumb place along with the progress bar, but, it's the thumb length from it's beginning to it's center point so that the seekbar can adjust the thumb's center point at it's beginning point. So, if we have a thumb image with a width of 50, the thumbOffset has to be 25 (50/2), so that the seekbar will adjust the zero value at the pixel 25 of the thumb which will make the thumb appears to be exactly at the middle. thanks for that man who redirect me to know that.

这篇关于搜索栏拇指中心不是在起点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆