2016-06-03 11 views
1

Ich habe eine Ansicht (Seekbar), in der ich eine zeichnungsfähige Form namens seek_bar.xml setzen in progressDrawable, aber ich bekomme ein anderes Ergebnis, wenn ich das Layout in verschiedenen Ebenen api ausführen. Bedeutet, wenn ich das Layout in < 21 die Größe der Form scheint zu klein, aber wenn ich das Layout ausführen> = 21 Formgröße scheint perfekt, bitte helfen Sie mir, wie dieses Problem API-Ebene für dieses Layout zu beheben. Siehe die Bilder.Wie man eine Zeichenform in android: progressDrawable in Suchleiste (Formgröße in <21 Api und vergrößert in> = 21 api)

und meine appcompct-Version ist.

compile 'com.android.support:appcompat-v7:23.1.1' 

<21 api level layout look >=21 api level looks perfect

Ich habe ein confirm.xml Code benannte Ansicht sieht aus wie

<LinearLayout 
    android:layout_centerInParent="true" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/dialog_background" 
    android:orientation="vertical" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

    <TextView 
     android:id="@+id/txt_dia" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_gravity="center" 
     android:layout_marginBottom="10dp" 
     android:layout_marginTop="40dp" 
     android:layout_weight="1" 
     android:gravity="center_horizontal" 
     android:paddingLeft="10dp" 
     android:paddingRight="10dp" 
     android:text="@string/dialog_title_logout" 
     android:textColor="@color/gray_dark" 
     android:textSize="@dimen/dialog_text_title" 
     android:textStyle="bold" 
     > 
    </TextView> 

    <RelativeLayout 
     android:id="@+id/yes_no_back_strip" 
     android:layout_width="match_parent" 
     android:layout_height="70dp" 
     android:layout_below="@+id/swipe_btn" 
     android:layout_marginBottom="15dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     > 

     <SeekBar 
      android:id="@+id/unlockButton" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:clickable="false" 
      android:max="100" 
      android:progress="50" 
      android:thumb="@drawable/slide_thumb" 
      android:splitTrack="false" 
      android:paddingLeft="1dp" 
      android:paddingRight="1dp" 
      android:thumbOffset="1dp" 
      android:paddingTop="5dp" 
      android:paddingBottom="5dp" 
      android:progressDrawable="@drawable/seek_bar" 
      /> 

     <LinearLayout 
      android:id="@+id/yes_no_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginBottom="10dp" 
      android:layout_marginTop="10dp" 
      android:orientation="horizontal" 
      android:visibility="visible" 
      > 

      <TextView 
       android:id="@+id/confirm_btn" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 
       android:layout_gravity="center" 
       android:layout_weight="1" 
       android:gravity="left|center_vertical" 
       android:paddingLeft="15dp" 
       android:text="@string/btn_txt_yes" 
       android:textColor="@color/gray_light_high" 
       android:textSize="@dimen/common_text_size" 
       android:textStyle="bold" 
       /> 

      <TextView 
       android:id="@+id/cancel_btn" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 
       android:layout_gravity="center" 
       android:layout_weight="1" 
       android:gravity="right|center_vertical" 
       android:paddingRight="15dp" 
       android:text="@string/btn_txt_no" 
       android:textColor="@color/gray_light_high" 
       android:textSize="@dimen/common_text_size" 
       android:textStyle="bold" 
       /> 
     </LinearLayout> 

    </RelativeLayout> 

</LinearLayout> 

und mein seek_bar.xml ist ....

 <?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:angle="0" 
       android:startColor="#ffe0db" 
       android:centerColor="#aeff6960" 
       android:endColor="#ff0002" 
       /> 
      <corners android:radius="35dip" /> 
      <size android:height="49dp" 
        android:width="190dp"/> 
     </shape> 
    </item> 
    <item android:id="@android:id/progress"> 
     <clip > 
      <shape> 
       <gradient 
        android:angle="0" 
        android:startColor="#0b6e07" 
        android:centerColor="#75ba70" 
        android:endColor="#97ba93" 
        /> 
       <corners android:radius="35dp" 
        /> 
       <size android:height="49dp" 
         android:width="190dp"/> 
      </shape> 
     </clip> 
    </item> 
</layer-list> 

Antwort

3

In API-Ebene> 20 Android: Breite und Android: Höhe funktioniert nicht mit Form, ich meine, es erkennt automatisch die richtige Höhe und Breite entsprechend der Ansicht, aber es ist nicht der Fall, wenn Sie die API verwenden Level < 20. Also wenn Sie die minimale Breite und Höhe fixieren, bleibt es durch alle Api Ebenen fixiert. Ansonsten können Sie eine andere -2 Layoutgröße angeben. Nur minHight und maxHight in Ihrem seekbar Layout

<Seekbar 
    ..... 
    android:minHeight="50dp" 
    android:maxHeight="50dp" 
    .... 
/> 
+0

wow es funktionierte für mich –

+0

Vielen Dank. Auf der Suche nach 10 Stunden. –

0

Hoffnung Dies könnte für alle APIs helfen:

+0

i müde hinzufügen, aber es ist nicht zu arbeiten. –

+0

Eigentlich ist das Problem in android: progressDrawable nicht in android: Hintergrund –