如何控制机器人的体积? [英] How to control volume in android?
问题描述
Android有硬件按钮控制音量(增加/减少)。 我想相同的功能使用按钮在我的视觉音量控制应用程序,它应该经过一段时间(秒)消失。
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).
推荐答案
您需要使用 AudioManager
类。开发者文档是这里。根据您想要的音量调节(振铃/媒体),您可能需要通过 AudioManager
更改audiomode。
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
.
最后,为了使按钮消失只是使用View.GONE他们。我想创建一个的Runnable
在 onClickListener
和使用 postDelayed
让查看
消失。
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.
这篇关于如何控制机器人的体积?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!