将定制拇指定位于seekbar中心的问题

问题描述:

我试图改变seekbar的宽度并使其变薄。但我的拇指不在seekbar的中心。 Thumb是一个自定义的9个补丁映像。将定制拇指定位于seekbar中心的问题

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/relLayout" 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
> 
    <SeekBar 
     android:paddingLeft="60dp" 
     android:progressDrawable="@drawable/seekbar_progress" 
     android:progress="0" 
     android:layout_height="20dp" 
     android:layout_width="fill_parent" 
     android:id="@+id/frequency_slider" 
     android:max="1" 
     android:paddingRight="60dp" 
     android:minWidth="60dp" 
     android:minHeight="60dp" 
     android:layout_alignParentRight="true" 

     android:thumb="@drawable/seek_normal_thumb" > 
     </SeekBar> 



</RelativeLayout> 
<WebView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/webkit" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/relLayout" 
    android:layout_alignParentTop="true" 
/> 
</RelativeLayout> 
+0

请发布整个XML布局 – Rejinderi 2011-05-21 13:00:23

+0

2011-05-21 14:43:45

我这样做是正确定义了minHeight和maxHeight搜索条

+0

我只需要设置maxHeight。 :)至于如何设置它:我只是试验了不同的dp值,直到它看起来正确。 – Chani 2013-02-20 21:10:40

+0

对我来说这是android:maxHeight =“60dp”。真酷!谢谢 – 2014-12-16 12:03:53

的定义与maxHeight的大值的属性后:

android:maxHeight="1000dp" 

搜索栏将调整为中心

+0

这工作,谢谢。我想知道为什么? – formatc 2015-07-08 06:15:53

+0

我想它是连接到如何getMinimumHeight()Drawable类的方法工作。这是Javadoc返回的一个解释:“该Drawable建议的最小高度,如果该Drawable没有建议的最小高度,则返回0。 – Andrey 2015-07-08 06:44:56