android 控制手机音量大小,android 控制手机音量的大小 切换声音的模式

(1)程序说明

在android API的AudioManager中,提供了调节手机音量的办法。

audioMa.adjustVolume(AudioManager.ADJUST_LOWER, 0);

audioMa.adjustVolume(AudioManager.ADJUST_RAISE, 0);也可以调节手机声音的模式为震动或者静音

audioMa.setRingerMode(AudioManager.RINGER_MODE_NORMAL);

audioMa.setRingerMode(AudioManager.RINGER_MODE_SILENT);

audioMa.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);

(2)布局文件

android:id="@+id/layout1"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/white"

xmlns:android="http://schemas.android.com/apk/res/android"

>

android:id="@+id/myText1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/str_text1"

android:textSize="16sp"

android:textColor="@drawable/black"

android:layout_x="20px"

android:layout_y="42px"

>

android:id="@+id/myImage"

android:layout_width="48px"

android:layout_height="48px"

android:layout_x="110px"

android:layout_y="32px"

>

android:id="@+id/myText2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/str_text2"

android:textSize="16sp"

android:textColor="@drawable/black"

andro

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值