Android拇指不在seekbar中居中?
我已经搜索了几个小时的解决方案,但没有找到。这是我的问题,正如我所看到的,这是一个非常普遍的问题: 大拇指在seekbar,没有居中。。。我用9patch定制了这款seekbar。 据说我应该在stackoverflow中的许多响应中将其minHeight和maxHeight设置为相同的大小。但即使我设置了它们,它仍然像这样显示。。。 这真是令人不安,有没有办法解决这个问题 下面是xml:Android拇指不在seekbar中居中?,android,slider,seekbar,Android,Slider,Seekbar,我已经搜索了几个小时的解决方案,但没有找到。这是我的问题,正如我所看到的,这是一个非常普遍的问题: 大拇指在seekbar,没有居中。。。我用9patch定制了这款seekbar。 据说我应该在stackoverflow中的许多响应中将其minHeight和maxHeight设置为相同的大小。但即使我设置了它们,它仍然像这样显示。。。 这真是令人不安,有没有办法解决这个问题 下面是xml: <SeekBar android:id="@+id/seek" android
<SeekBar
android:id="@+id/seek"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/padding_small"
android:max="100"
android:progress="60"
android:maxHeight="@dimen/playerSeekBarHeight"
android:minHeight="@dimen/playerSeekBarHeight"
android:progressDrawable="@drawable/progress_bar_player"
android:thumb="@drawable/player_sound_thumb"
android:paddingLeft="6dp"
android:paddingRight="6dp" />
提前谢谢。试试这个
seekbar_progress_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<clip >
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="left"
android:src="@drawable/progress_bar_player">
</bitmap>
</clip>
</item>
seekbar_progress.xml
<?xml version="1.0" encoding="utf-8"?>
xml
从这个链接找不到解决这个问题的方法,仍然不知道是什么问题。为什么将minHeight和maxHeight设置为每个人的相同大小,但在我的情况下不是这样?总之,我把一些空像素放进拇指图像中,它就工作了
但我希望有更有效的方法来处理这种情况。在我的情况下,设置最小高度和最大高度也不起作用
我是通过使用minHeight和maxHeight值来实现的。将minHeight设置为比maxHeight大近2倍或更多对我来说是个好办法。尝试为两者设置不同的值。应该锻炼…是的,最小高度最大高度也不适合我。我的问题是当我决定为高分辨率屏幕创建布局时。当我把屏幕上的每一行都放大时,我想我可以“匹配父母”的高度,这样就好了。但是没有,我有上面的问题 我通过返回到高度的“wrap_content”,删除minHeight和maxHeight标签,然后使用layout_marginTop将其向下移动到水平线布局的中心来解决这个问题 我使用的是默认的seekbar
希望这对别人有帮助 使用“向下填充”或“顶部填充”…这将为整个栏提供填充,而不仅仅是拇指:/ok..你的拇指图像在顶部有额外的空间..尝试此链接@selva也检查了这一点,但没有,它没有任何空间。:/我已经看到了这个url,正如我说的,它们被设置为相同的大小。也许你的seekbar的父视图的高度太小了
<item android:id="@android:id/background">
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="@drawable/whitepatch">
</nine-patch>
</item>
<item android:id="@android:id/secondaryProgress">
<clip >
<shape >
<gradient
android:angle="270"
android:centerColor="#80127fb1"
android:centerY="0.75"
android:endColor="#a004638f"
android:startColor="#80028ac8">
</gradient>
</shape>
</clip>
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/seekbar_progress_bg">
</item>
<SeekBar
android:id="@+id/seekbar_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="420dip"
android:layout_height="wrap_content"
android:layout_marginLeft="0dip"
android:layout_marginTop="12dip"
android:maxHeight="9dp"
android:minHeight="9dp"
android:progressDrawable="@drawable/seekbar_progress"
android:thumb="@drawable/player_sound_thumb" />