Implementing Simple SeekBar in android
First, I think you should extend SeekBar
.
Second, call canvas.drawText()
in onDraw()
method to draw text before SeekBar
and after SeekBar
.
This way you can refresh the textView
in your onDraw
method callback
You have already defined max value of seekbar
android:max="100"
Now you need to add two textviews on left and right of seekbar. Use Relative layout and align both textviews Left and Right to the parent.
Brontok's hint solved my problem. I just had to alter the XML. I want to share the result here:
<RelativeLayout
android:id="@+id/relativeLayoutforPRICE"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/PRICEtextViewProgressID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Price"
android:textAppearance="?android:attr/textAppearanceLarge" >
</TextView>
<SeekBar
android:id="@+id/PRICEseekBarID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="26dp"
android:max="100" >
</SeekBar>
<TextView
android:id="@+id/PRICEinitialvaluetextID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/PRICEseekBarID"
android:text="Rs 0" >
</TextView>
<TextView
android:id="@+id/PRICEinitialvaluetextID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/PRICEseekBarID"
android:text="Rs 100" />
</RelativeLayout>