Dhaval
Dhaval

Reputation: 11

Seekbar progress drawable show wrong issue when its progess value is zero

I am new in android platform. I am trying to develop the custom seek bar using .9 path image and xml.I created almost but my problem is occurs when seekbar is appear first time when activity start its show wrong progress level when my progess level is define 0 in xml. you check out image

enter image description here

Here my xml file code

        <Seekbar
            android:id="@+id/Slider1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:progress="0"
            android:splitTrack="false"
            android:layout_marginTop="5px"
            android:layout_marginBottom="5px"
            android:background="@android:color/transparent"
            android:progressDrawable="@drawable/green_seekbar"
            android:thumb="@drawable/slidercontralbt2" />

green_seekbar.xml

<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="@drawable/sb"
        android:dither="true"
     />
</item>
 <item
    android:id="@android:id/progress"
    android:drawable="@drawable/green_seekbar_progress"
/>

green_seekbar_progress.xml

<?xml version="1.0" encoding="utf-8"?>

<item >
  <clip>
    <nine-patch
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/green"
        android:dither="true"
     />
    </clip>  
  </item>

Upvotes: 0

Views: 922

Answers (1)

Dhaval
Dhaval

Reputation: 11

Finally The reach to the solution. Put the below code in the onCreate method.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    .....
    .....
    Slider1.setProgress(0);
    Slider1.invalidate();

}

Upvotes: 1

Related Questions