Android has the Hardware button for controlling volume (increase/decrease). I want to same functionality by using buttons in my application with visual volume control and it should be disappeared after some time (in sec).
Open Settings on your Android phone by clicking the gear icon. Then, head over to the sound and vibrations option. You will see a few volume sliders adjusting the volume of media, ringtone, notifications, and alarms, now you just need to adjust the volume and that's it.
To change the sound volume, open the system menu from the right side of the top bar and move the volume slider left or right. You can completely turn off sound by dragging the slider to the left. Some keyboards have keys that let you control the volume.
Volume Control is one very feature-rich app that will give you full control over the volume settings. For example, by swiping down from the top of the display, you'll see the volume settings for the alarm, multimedia, notifications, ringer, system, calls, and Bluetooth.
You need to use the AudioManager
class. Developer doc is here. Depending on which volume you want to adjust (ringer/media) you may need to change the audiomode via AudioManager
.
Finally, to make the buttons disappear just use View.GONE on them. I would create a Runnable
in the onClickListener
and use a postDelayed
to make the View
disappear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With