[英]Android seekbar clipped thumb
I ran into some weird problem..I implemented a seekbar with custom thumb..and when I ran my app on HTC Desire, it all works fine..but, when I ran it on Samsung Galaxy, the thumb becomes clipped! 我遇到了一些奇怪的问题..我用自定义拇指实现了一个搜索栏。当我在HTC Desire上运行我的应用程序时,一切正常。但是,当我在三星Galaxy上运行它时,拇指会被剪掉!
Here are the screenshots.. 这是截图..
Desire: 欲望:
Samsung Galaxy: 三星Galaxy:
I would be grateful for any thoughts..tnx 如果有任何想法,我将不胜感激.tnx
myprogress.xml: myprogress.xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners
android:radius="10dp" />
<gradient
android:startColor="@color/gray"
android:centerColor="@color/gray"
android:centerY="0.75"
android:endColor="@color/gray"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners
android:radius="10dp" />
<gradient
android:startColor="@color/white"
android:centerColor="@color/white"
android:centerY="0.75"
android:endColor="@color/white"
android:angle="270"
/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners
android:radius="10dp" />
<gradient
android:startColor="#FFA500"
android:centerColor="@color/yellow"
android:centerY="0.75"
android:endColor="@color/yellow"
android:angle="270"
/>
</shape>
</clip>
</item>
style: 样式:
<style name="mySeekBar">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/myprogress</item>
<item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item>
<item name="android:minHeight">10dip</item>
<item name="android:maxHeight">10dip</item>
<item name="android:thumb">@drawable/thumb</item>
<item name="android:thumbOffset">4dp</item>
<item name="android:focusable">true</item>
seekbar xml: seekbar xml:
<SeekBar android:id="@+id/player_seek_horizontal"
android:layout_gravity="center_vertical"
android:max="100"
android:layout_marginLeft="50dp"
android:layout_width="180dp"
android:thumb="@drawable/thumb"
android:layout_height="wrap_content"
style="@style/mySeekBar"
android:background="@drawable/background_transparent_rounded"
android:paddingRight="4dp" android:paddingLeft="4dp"/>
Adjust the android:paddingLeft
, android:paddingRight
and android:thumbOffset
properties of your SeekBar
to achieve desired results. 调整你的
SeekBar
的android:paddingLeft
, android:paddingRight
和android:thumbOffset
属性,以达到预期的效果。
Padding right and left should be half of thumb's width. 左右填充应为拇指宽度的一半。
<SeekBar
...
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:thumbOffset="0px" />
It worked for me. 它对我有用。
add following attributes to your parent layout 将以下属性添加到父布局
android:clipChildren="false"
android:clipToPadding="false"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.