1

在設備上繪製的行爲,運行Android API < = 22,我的自定義搜索欄如下所示: enter image description here奇怪的定製搜索欄上不同的API

在設備上運行Android API> = 23,我的自定義搜索欄如下所示: enter image description here

爲什麼我的SeekBar drawable在設備API> = 23上看起來不正確?這裏是我的XML

seekbar_progress.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:drawable="@drawable/seekbar_progress_bg" /> 
<item android:id="@android:id/progress"> 
    <scale 
     android:drawable="@drawable/seekbar_progress_fill" 
     android:scaleWidth="100%" /> 
</item> 

</layer-list> 

seekbar_thumb.xml

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item> 
    <shape android:shape="oval"> 
     <size 
      android:width="@dimen/seekbar_thumb" 
      android:height="@dimen/seekbar_thumb" /> 
     <solid android:color="@color/white" /> 
     <stroke 
      android:width="@dimen/seekbar_thumb_border" 
      android:color="@color/gray" /> 
    </shape> 
</item> 
</layer-list> 

佈局文件

<SeekBar 
    android:thumb="@drawable/seekbar_thumb" 
    android:progressDrawable="@drawable/seekbar_progress" 
    android:splitTrack="true" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    tools:progress="50" /> 

回答

1

由於未知的原因,通過玩minHeight和maxHeight,我能夠獲得所需的行爲