2014-11-18 22 views
35

Đây là tôi seekbar:thumb Tuỳ chỉnh seekbar không minh bạch trên Lollipop API21

<SeekBar 
    android:id="@+id/seek1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    android:progressDrawable="@drawable/style_progressbar" 
    android:thumb="@drawable/style_progressbar_circle" 
    android:progress="20" /> 

Đây là style_progressbar.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:id="@android:id/background"> 
     <shape android:shape="rectangle" > 
      <corners android:radius="5dp" /> 
      <gradient 
       android:angle="270" 
       android:endColor="@color/gris_hint" 
       android:startColor="@color/gris_hint" /> 
     </shape> 
    </item> 
    <item android:id="@android:id/secondaryProgress"> 
     <clip> 
      <shape android:shape="rectangle" > 
       <corners android:radius="5dp" /> 
       <gradient 
        android:angle="270" 
        android:endColor="@color/gris" 
        android:startColor="@color/gris" /> 
      </shape> 
     </clip> 
    </item> 
    <item android:id="@android:id/progress"> 
     <clip> 
      <shape android:shape="rectangle" > 
       <corners android:radius="5dp" /> 
       <gradient 
        android:angle="270" 
        android:endColor="@color/gris" 
        android:startColor="@color/gris" /> 
      </shape> 
     </clip> 
    </item> 
</layer-list> 

Và đây là style_progressbar_circle.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@drawable/red_scrubber_control_disabled_holo" android:state_enabled="false"/> 
    <item android:drawable="@drawable/red_scrubber_control_pressed_holo" android:state_pressed="true"/> 
    <item android:drawable="@drawable/red_scrubber_control_focused_holo" android:state_selected="true"/> 
    <item android:drawable="@drawable/red_scrubber_control_normal_holo"/> 
</selector>  

Đây là cách Tôi nhìn thấy nó trong Lollipop

Seekbar Lollipop

Đây là cách nó nên nhìn, đây là cách có vẻ trên Kitkat và các phiên bản thấp hơn.

Seekbar KitKat

Bất kỳ ý tưởng nào? Tôi có một số vấn đề với bố trí trên Lollipop nhưng đây là điều duy nhất tôi không thể giải quyết cho riêng mình.

+0

Tôi có vấn đề tương tự. Tôi đã tạo báo cáo lỗi android https://code.google.com/p/android/issues/detail?id=79885 –

Trả lời

49

Thanh tìm kiếm tài liệu có theo dõi chia được bật theo mặc định. Bạn cần tắt nó đi.

<SeekBar 
    .... 
    android:splitTrack="false" /> 
+2

Hoạt động như sự quyến rũ. Cảm ơn. Các nút material có textAllCaps được bật theo mặc định, cùng một vấn đề. –

+7

Mẹo nhỏ. Để ghi đè hiệu ứng vật liệu giữ ngón tay cái, nó đủ để đặt lại nền: android: background = "@ null" –

+0

@SergeyVakulenko tuyệt vời! Cảm ơn nhiều! – rocknow

Các vấn đề liên quan