如何控制机器人的体积? [英] How to control volume in android?

查看:191
本文介绍了如何控制机器人的体积?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆