2015-09-25 20 views
1

请查看我想要实现的自定义seekbar的以下屏幕截图。 enter image description here如何删除已设置自定义进度的seekbar [android]的默认指标图标可绘制

我非常接近建立如上所示的seekbar(没有在seekbar下面的图像)。以下是我所做的截图。

enter image description here

问题:

正如你可以在第二个截图中看到,有在搜索条进度指示条后的图标。我一直试图摆脱这一点,但显然不成功做到这一点。任何关于如何移除该图标的建议/想法都会有很大的帮助。谢谢。使用

搜索栏布局XML

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="com.application.todo.activityTransition.activities.SeekBarActivity"> 

<TextView 
    android:id="@+id/painLevelText" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:padding="10dp" 
    android:text="@string/painLevelText" /> 

<LinearLayout 
    android:id="@+id/radIoGroupLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/painLevelText" 
    android:orientation="vertical"> 

    <RadioGroup 
     android:id="@+id/seekBarRadioGroup" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:weightSum="10"> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <RadioButton 
      android:id="@+id/defaultSelection" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 
    </RadioGroup> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="10dp" 
     android:orientation="horizontal" 
     android:weightSum="10"> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="1" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="2" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="3" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="4" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="5" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="6" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="7" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="8" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="9" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="10" /> 

    </LinearLayout> 

</LinearLayout> 

<RelativeLayout 
    android:id="@+id/seekBarLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/radIoGroupLayout" 
    android:background="@drawable/seekbar_layout_background"> 

    <SeekBar 
     android:id="@+id/seekBar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:max="10" 
     android:progress="5" 
     android:progressDrawable="@drawable/custom_seek_bar" /> 

    <TextView 
     android:id="@+id/seekBarProgressValue" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:gravity="center" 
     android:padding="10dp" 
     android:textColor="#FFF" 
     android:textSize="15sp" /> 
</RelativeLayout> 


</RelativeLayout> 

自定义绘制对象文件搜索条

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:id="@android:id/progress"> 
    <clip> 
     <shape android:shape="rectangle"> 
      <size 
       android:width="12dp" 
       android:height="12dp" /> 
      <corners android:radius="15dp" /> 

      <solid android:color="#FF8D1E" /> 

      <gradient 
       android:angle="270" 
       android:centerColor="#FF8D1E" 
       android:endColor="#FF971F" 
       android:startColor="#FF971F" /> 
     </shape> 
    </clip> 
</item> 
</layer-list> 

请找我下答案部分答案

+1

检查URL http://stackoverflow.com/questions/20855815/how-to-hide- show-thumb-draw-in-a-seekbar – Pavya

+0

请张贴您的活动代码 –

回答

5

link有助于实现预期的结果。但是我发现一个问题,而使用下面的一行代码

seekBar.getThumb().mutate().setAlpha(0); 

它取出拇指在最后,但是当我们从RadioGroup中选择“10”进度指示器被砍伤。以下是相关图片。

enter image description here

但是,当我在我的布局中使用的XML标签中的搜索条,有人按预期工作。

android:thumb="@null" 

图片

enter image description here

不知道这是正确的做法,但它的伎俩。

0

我不认为做SeekBar是正确的实现你的用例。尝试使用ProgressBar代替,那么你不必担心拇指。

+0

Hey Kent,感谢您在发布回复时的时间。你能建议任何链接/参考,我可以找到关于进度条实施入门的信息吗? –

+0

只需在您的XML布局和您的活动/片段中将ProgressBar替换为SeekBar,您应该没问题。 –

+0

会很快做到这一点,并发布更新 –

1

试试这个

android:splitTrack="false" 
seekbar.getThumb().mutate().setAlpha(0); 
1

只是把这个线在你的搜索栏的XML代码..

  android:thumbTint="@android:color/transparent" 
相关问题