MediaPlayer, ProgressBar

Personally, I start off a Thread that checks getCurrentPosition() every 200ms or so until the onCompletion() event gets fired off: private class MediaObserver implements Runnable { private AtomicBoolean stop = new AtomicBoolean(false); public void stop() { stop.set(true); } @Override public void run() { while (!stop.get()) { progress.setProgress(mediaPlayer.getCurrentPosition()); Thread.sleep(200); } } } private MediaObserver observer = … Read more

Modifying the Android seekbar widget to operate vertically

I’ve created a solution which works (at least for me, anyway) and creates a vertical SeekBar. http://hackskrieg.wordpress.com/2012/04/20/working-vertical-seekbar-for-android/ This code will correctly select/deselect the thumb, move correctly, update the listener correctly (only when the progress changes!), update/draw the progress correctly, etc. I hope it helps you. public class VerticalSeekBar extends SeekBar { public VerticalSeekBar(Context context) { … Read more

Using SeekBar to Control Volume in android?

Please look at below code . It solves your problem. import android.app.Activity; import android.content.Context; import android.media.AudioManager; import android.os.Bundle; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; public class TestExample extends Activity { /** Called when the activity is first created. */ private SeekBar volumeSeekbar = null; private AudioManager audioManager = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setVolumeControlStream(AudioManager.STREAM_MUSIC); … Read more

Add dynamic text over Android SeekBar thumb

I have followed a different approach which provides more possibilities to customize the thumb. Final output will look like following: First you have to design the layout which will be set as thumb drawable. layout_seekbar_thumb.xml <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:orientation=”vertical”> <LinearLayout android:layout_width=”@dimen/seekbar_thumb_size” android:layout_height=”@dimen/seekbar_thumb_size” android:background=”@drawable/ic_seekbar_thumb_back” android:gravity=”center” android:orientation=”vertical”> <TextView android:id=”@+id/tvProgress” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”0″ android:textColor=”#000000″ … Read more

Custom seekbar (thumb size, color and background)

All done in XML (no .png images). The clever bit is border_shadow.xml. All about the vectors these days… Screenshot: This is your SeekBar (res/layout/???.xml): SeekBar <SeekBar android:id=”@+id/seekBar_luminosite” android:layout_width=”300dp” android:layout_height=”wrap_content” android:progress=”@integer/luminosite_defaut” android:progressDrawable=”@drawable/seekbar_style” android:thumb=”@drawable/custom_thumb”/> Let’s make it stylish (so you can easily customize it later): style res/drawable/seekbar_style.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/border_shadow” > … Read more

How to make a vertical SeekBar in Android?

For API 11 and later, can use seekbar’s XML attributes(android:rotation=”270″) for vertical effect. <SeekBar android:id=”@+id/seekBar1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:rotation=”270″/> For older API level (ex API10), only use Selva’s answer: https://github.com/AndroSelva/Vertical-SeekBar-Android

How can I get a working vertical SeekBar in Android?

Here is a working VerticalSeekBar implementation: package android.widget; import android.content.Context; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.MotionEvent; public class VerticalSeekBar extends SeekBar { public VerticalSeekBar(Context context) { super(context); } public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public VerticalSeekBar(Context context, AttributeSet attrs) { super(context, attrs); } protected void onSizeChanged(int w, int h, … Read more