Trouble positioning customized thumb at the centre of seekbar

a 夏天 提交于 2019-12-10 19:11:15

问题


I tried to change the width of seekbar and made it thin. But my thumb is not coming at the centre of seekbar. Thumb is a customised 9 patch image.

    <?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>

回答1:


I got it right by defining minHeight and maxHeight of the seekbar




回答2:


After defining an attribute with big value of maxHeight:

android:maxHeight="1000dp"

SeekBar will be adjusted to the center



来源:https://stackoverflow.com/questions/6081832/trouble-positioning-customized-thumb-at-the-centre-of-seekbar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!