0

Freunde, hilf mir bitte. Ich habe eine benutzerdefinierte SeekBar im Projekt. Es wird nicht korrekt angezeigt. http://take.ms/NgHW9 enter image description hereBenutzerdefinierte Suchleiste funktioniert nicht richtig

        <LinearLayout 
             android:layout_width="match_parent" 
             android:layout_height="wrap_content" 
             android:layout_weight="1" 
             android:background="@mipmap/ballance_bg" 
             android:gravity="center" 
             android:padding="2dp"> 

             <SeekBar 
              android:id="@+id/seekBar" 
              android:layout_width="match_parent" 
              android:layout_height="wrap_content" 
              android:layout_gravity="center" 
              android:clickable="false" 
              android:focusable="false" 
              android:max="1" 
              android:maxHeight="5dp" 
              android:minHeight="1dp" 
              android:paddingLeft="1dp" 
              android:paddingRight="1dp" 
              android:progress="0" 
              android:progressDrawable="@drawable/seekbar_progress" 
              android:saveEnabled="true" 
              android:thumb="@mipmap/point_icon" 
              android:thumbOffset="0dp" /> 
            </LinearLayout> 

Es gibt individuelle ziehbar Ressource - seekbar_progress

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:id="@android:id/background"> 
    <nine-patch 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:src="@mipmap/like_line_2" 
     android:dither="true"/> 
</item> 
<item 
    android:id="@android:id/progress" 
    android:drawable="@drawable/red_seekbar_progress" /></layer-list> 

Die like_line_2 9.patch Bild ist

Es individuelle ziehbar Ressource - red_seekbar_progress

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item > 
    <clip> 
     <nine-patch 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:src="@mipmap/dislike_line_2" 
      android:dither="true" 
      /> 
    </clip> 
</item></layer-list> 

Die dislike_line_2 ist 9.patch image

Dieser Code füllt SeekBar.

seek_1 = (SeekBar) view.findViewById(R.id.seekBar); 
seek_1.setOnTouchListener(new View.OnTouchListener() { 
@Override 
public boolean onTouch(View view, MotionEvent motionEvent) { 
    return true; 
} 
}); 
int sum = Integer.parseInt(products.get(0).getPositive_count()) + Integer.parseInt(products.get(0).getNegative_count()); 
seek_1.setMax(sum); 
seek_1.setProgress(Integer.parseInt(products.get(0).getNegative_count())); 

Dieser Fehler tritt in verschiedenen SeekBars

+0

fand ich die Lösung selbst. Da war der Fehler. –

Antwort

0

fand ich die Lösung selbst. Da war der Fehler.

<item 
android:id="@android:id/progress" 
android:drawable="@drawable/red_seekbar_progress" /> 

Versuchen Sie nicht für XML in Element ein anderes XML zu verwenden.

korrekte Version:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item android:id="@android:id/background"> 
<nine-patch 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:src="@mipmap/like_line_2" 
    android:dither="true"/> 
</item> 
<item 
    android:id="@android:id/progress"> 
    <clip> 
     <nine-patch 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:src="@mipmap/dislike_line_2" 
      android:dither="true"/> 
    </clip> 
    </item> 
</layer-list>