Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Android volume bar

When you are in an Instagram story, and you decide to raise or lower the volume, this custom bar appears

Volume bar on Instagram app

Instead, the normal volume bar looks like this

Default volume bar on my Android phone

I've researched ways to do it, but haven't found any.

How do I make this effect in Android Studio?

PD: I want to make this effect only when a person is using my application NOT to change the volume bar on the Android system

like image 869
Bohosul Avatar asked Aug 13 '20 16:08

Bohosul


1 Answers

Use Key Event to find control of volume up and down button like this.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_UP:
            return true;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            return true;
        default:
            break;
    }
    return super.onKeyDown(keyCode, event);
}

And then create a custom seek bar and control the seek bar progress with the button control. Hope it works.

like image 191
Geek Tanmoy Avatar answered Sep 24 '22 17:09

Geek Tanmoy