2015-05-18 190 views
1

我在我的SeekBar和拇指后面找到一个随机阴影,出于某种奇怪的原因(黑暗而不是黑色部分)。我如何摆脱它?删除SeekBar阴影

image of shadow

我的搜索栏:

<SeekBar android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/slider" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:max="10" 
    android:thumb="@drawable/thumb" 
    android:progressDrawable="@drawable/progress_appearance"/> 

thumb.xml

<?xml version="1.0" encoding="UTF-8"?> 
<shape 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 

<gradient 
    android:startColor="#ffffffff" 
    android:endColor="#ffffffff"/> 

<size android:height="20dp" android:width="20dp"/> 
</shape> 

progress_appearance.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" 
    android:paddingTop="3px" 
    android:paddingBottom="3px"> 
    <shape> 
     <corners android:radius="100dip" /> 
     <gradient 
      android:startColor="#000" 
      android:centerColor="#000" 
      android:endColor="#000" 
      android:centerY="0.2" 
      android:angle="270"/> 
    </shape> 
</item> 

<item android:id="@android:id/progress"> 
    <clip> 
     <shape> 
      <corners android:radius="0dip" /> 
      <gradient 
       android:startColor="#000" 
       android:centerColor="#000" 
       android:endColor="#000"/> 
     </shape> 
    </clip> 
</item> 
</layer-list> 

回答

0

我正面临类似的问题。
经过一番挣扎之后,我发现当它有后面它没有出现阴影。
所以我终于把FrameLayout放在SeekBar后面。

The weird shadow

这里是我的代码。

<FrameLayout 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"> 

<!-- Putting this FrameLayout, I could remove the shadow. --> 
<FrameLayout 
    android:background="@android:color/white" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="70dp"> 
     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <!-- Thumbnail frames you see above --> 
      <ImageView 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1"/> 
      ... 
     </LinearLayout> 

     <!-- The SeekBar --> 
     <SeekBar 
      android:padding="0dp" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
     ... 

,因为我没有把任何东西前的的影子,但背后阴影这是非常奇怪的。
我认为这是Android的错误。

我希望它能帮助你:)

6

试试这个:

<SeekBar android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
///// 
     android:background="@null" 
///// 
     android:id="@+id/slider" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:max="10" 
     android:thumb="@drawable/thumb" 
     android:progressDrawable="@drawable/progress_appearance"/> 
1

我用这个代码:

<SeekBar 
    android:id="@+id/seekbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:max="100" 
    android:background="@null" 
    android:padding="0dp" 
    android:progressDrawable="@drawable/progress_seekbar" 
    android:thumb="@android:color/transparent" /> 

它为我工作。

+0

这应该是被接受的答案:android:background =“@ null”正常。 – IlToro