Android SeekBar 拇指被剪裁/切断
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2912609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android SeekBar thumb gets clipped/cut off
提问by Jana
When using a custom thumb drawable with a SeekBarview, the thumb drawable is clipped at the left and right edges of the view.
在SeekBar视图中使用自定义拇指可绘制时,拇指可绘制在视图的左右边缘被剪裁。
How can I fix this behavior?
我该如何解决这种行为?
回答by Roman Nurik
You should be able to fix this by setting paddingLeftand paddingRighton your SeekBarto half the thumb width (remember to use density-independent units). You can also control the space allowed at the edges for a seek bar's thumb by calling setThumbOffset.
您应该能够通过设置来解决这个问题paddingLeft,并paddingRight在你SeekBar的一半,拇指宽度(记得要使用密度独立单位)。您还可以通过调用 来控制搜索栏拇指边缘允许的空间setThumbOffset。
回答by Nicholi
I ran into this issue myself, and I believe the "correct"decision would be to modify android:thumbOffsetas the default style for a SeekBarsets it to 8px.
我自己遇到了这个问题,我相信"correct"决定是修改android:thumbOffset为SeekBar的默认样式将其设置为 8px。
回答by kayz1
For default SeekBar I used these settings and it works fine:
对于默认的 SeekBar,我使用了这些设置并且它工作正常:
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:thumbOffset="8dp"
回答by kakopappa
Just for clarification.
只是为了澄清。
On some places I have seen
在我见过的一些地方
android:thumbOffset="8dp"
and some
还有一些
android:thumbOffset="8px"
so I looked at the source code. this is the original style
所以我查看了源代码。这是原来的风格
<style name="Widget.SeekBar">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
<item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item>
<item name="android:minHeight">20dip</item>
<item name="android:maxHeight">20dip</item>
<item name="android:thumb">@android:drawable/seek_thumb</item>
<item name="android:thumbOffset">8dip</item>
<item name="android:focusable">true</item>
</style>
from
从

