Search code examples
androidinstagramvolume

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


Solution

  • 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.