android - cant把拇指放在搜索栏的中心

emi*_*lia 8 android seekbar android-progressbar

我想知道如何将拇指设置在搜索栏的中心.不知道如何表达,所以我将添加图片的链接.第一个img是设计指南的搜索栏,下面是我的搜索栏.

在此输入图像描述

(忽略了角落.我在捕获了imgs之后修复了.)起初,从设计师那里,我得到了两个单独的img文本,无论好坏.所以我结合了那些.我以为它会像拇指一样工作.但现在我得到的是这些结果......请帮帮我..谢谢!

drawable:progressbar_goodbad xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
    <shape>
        <gradient
            android:startColor="#f5c0bd"
            android:centerColor="#f5c0bd"
            android:centerY="0.75"
            android:endColor="#f5c0bd"
            android:angle="270"/>
        <padding android:left="10dp"
            android:top="1dp"
            android:right="10dp"
            android:bottom="1dp"/> 
    <corners
        android:bottomRightRadius="10dp"
        android:bottomLeftRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp"/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
    <shape>
        <gradient
            android:startColor="#234"
            android:centerColor="#234"
            android:centerY="0.75"
            android:endColor="#a24"
            android:angle="90"/>
        <padding android:left="1dp"
            android:top="1dp"
            android:right="1dp"
            android:bottom="1dp"/> 
    <corners
        android:bottomRightRadius="10dp"
        android:bottomLeftRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp"/>
        </shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
   <shape>
        <gradient
            android:startColor="#fc9a94"
            android:centerColor="#fc9a94"
            android:centerY="0.75"
            android:endColor="#fc9a94"
            android:angle="90"/>
        <padding android:left="1dp"
            android:top="1dp"
            android:right="1dp"
            android:bottom="1dp"/> 
    <corners
        android:bottomRightRadius="10dp"
        android:bottomLeftRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp"/>
    </shape>
</clip>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)

主要布局xml的一部分

<SeekBar
     android:id="@+id/seekBar_fun"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_marginBottom="3dp"
     android:paddingLeft="10dp"
     android:paddingRight="10dp"
     android:max="100"
     android:progress="60"
     android:progressDrawable="@drawable/progressbar_goodbad"
     android:thumb="@drawable/f_02_good_bad_text" />
Run Code Online (Sandbox Code Playgroud)

Gui*_*eau 4

(答案在 Twinsens 链接中找到。)

您的拇指图像需要在中心(水平方向)有一个黄点;向左或向右添加透明像素以实现此目的。然后,更改android:thumbOffset为拇指图像大小的一半。例如,如果您的图像宽度为10dpandroid:thumbOffset ,则设置为5dp