如何在 Android 中以编程方式增加和减少音量
How to increase and decrease the volume programmatically in Android
我创建了一个音乐播放器应用程序,我想以编程方式设置音量 up/down。我想实现两个 Button
到 increase/decrease 音量并设置为媒体播放器。
Activity:
control = (ImageView) findViewById(R.id.control);
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
control.setOnClickListener(pausePlay);
control.setBackgroundResource(R.drawable.pause);
control id is my play and pause button :
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
if (playPause) {
control.setBackgroundResource(R.drawable.play);
if (mediaPlayer.isPlaying())
mediaPlayer.pause();
media.stop();
intialStage = false;
playPause = false;
} else {
control.setBackgroundResource(R.drawable.pause);
if (intialStage) {
new Player()
.execute("http://streaming.shoutcast.com/MUKILFMRADIO");
} else {
if (!mediaPlayer.isPlaying())
mediaPlayer.start();
}
playPause = true;
}
}
布局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/control1"
android:layout_margin="10dp"
android:layout_gravity="center"
android:background="@drawable/decrement"
android:layout_above="@+id/latestAddedSongs"
android:layout_alignEnd="@+id/musicArtistName" />
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/control"
android:layout_margin="10dp"
android:layout_gravity="center"
android:background="@drawable/play"
android:layout_above="@+id/latestAddedSongs"
android:layout_alignEnd="@+id/musicArtistName" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/control2"
android:layout_margin="10dp"
android:layout_gravity="center"
android:background="@drawable/increment"
android:layout_above="@+id/latestAddedSongs"
android:layout_alignEnd="@+id/musicArtistName" />
</LinearLayout>
试试下面的代码
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
seekbar.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int newVolume, boolean b) {
textview.setText("Media Volume : " + newVolume);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, newVolume, 0);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
为音频管理器创建对象
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
Button upButton = (Button) findViewById(R.id.upButton);
upButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//To increase media player volume
audioManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
}
});
Button downButton = (Button) findViewById(R.id.downButton);
downButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//To decrease media player volume
audioManager.adjustVolume(AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND);
}
});
上面的例子使用了Button标签
用于增大和减小音量
代码
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int action = event.getAction();
int keyCode = event.getKeyCode();
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
if (action == KeyEvent.ACTION_DOWN) {
audioManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
}
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (action == KeyEvent.ACTION_DOWN) {
audioManager.adjustVolume(AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND);
}
return true;
default:
return super.dispatchKeyEvent(event);
}
}
跟进jesu的解决方案,如果你想在服务中改变音量而不是Activity,替换:
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
与:
AudioManager audioManager;
audioManager = (AudioManager) YourServiceName.this.getSystemService(Context.AUDIO_SERVICE);
下面的代码效果很好
Android 中有几个可用的流可以用来管理音频
/** The audio stream for phone calls */
public static final int STREAM_VOICE_CALL = AudioSystem.STREAM_VOICE_CALL;
/** The audio stream for system sounds */
public static final int STREAM_SYSTEM = AudioSystem.STREAM_SYSTEM;
/** The audio stream for the phone ring */
public static final int STREAM_RING = AudioSystem.STREAM_RING;
/** The audio stream for music playback */
public static final int STREAM_MUSIC = AudioSystem.STREAM_MUSIC;
/** The audio stream for alarms */
public static final int STREAM_ALARM = AudioSystem.STREAM_ALARM;
/** The audio stream for notifications */
public static final int STREAM_NOTIFICATION = AudioSystem.STREAM_NOTIFICATION;
/** @hide The audio stream for phone calls when connected to bluetooth */
public static final int STREAM_BLUETOOTH_SCO = AudioSystem.STREAM_BLUETOOTH_SCO;
/** @hide The audio stream for enforced system sounds in certain countries (e.g camera in Japan) */
public static final int STREAM_SYSTEM_ENFORCED = AudioSystem.STREAM_SYSTEM_ENFORCED;
/** The audio stream for DTMF Tones */
public static final int STREAM_DTMF = AudioSystem.STREAM_DTMF;
/** @hide The audio stream for text to speech (TTS) */
public static final int STREAM_TTS = AudioSystem.STREAM_TTS;
根据您的需要,您可以在此处更改流 STREAM_MUSIC 示例:
您可以使用 AudioSytem 的反射获得常量值 class:
private int getStreamType(String streamName) {
final String streamSourceClassName = "android.media.AudioSystem";
int streamType = 0;
try {
streamType = (int) Class.forName(streamSourceClassName).getDeclaredField(streamName).get(null);
} catch (ClassNotFoundException | IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
return streamType;
}
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
seekbar.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int newVolume, boolean b) {
textview.setText("Media Volume : " + newVolume);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, newVolume, 0);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
如果你的类型是AudioManager.STREAM_MUSIC:使用这个代码,跟随phone音量按钮
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
audio.adjustStreamVolume(
AudioManager.STREAM_MUSIC,
AudioManager.ADJUST_RAISE,
AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
audio.adjustStreamVolume(
AudioManager.STREAM_MUSIC,
AudioManager.ADJUST_LOWER,
AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
return true;
default:
break;
}
return super.onKeyDown(keyCode, event);
}
AudioManager aManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
Button buttonUp= (Button) findViewById(R.id.upButton);
buttonUp.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
enter code here
//To increase media player volume
`enter code here`aManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
}
});
Button downButton = (Button) findViewById(R.id.downButton);
buttondown.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
aManager.adjustVolume(AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND);
}
});
此代码将在按下按钮 SES 时立即将音量设置为 100,而不会向用户反馈。
public void perform_actionSES(View v) {
Button buttonSES = (Button) findViewById(R.id.buttonSES);
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 100, 0);
}
各位编码员。我已尽力使代码尽可能简单。我希望这对某人有帮助。祝你有美好的一天!
我正在使用:
Android Studio 4.2.2
构建 #AI-202.7660.26.42.7486908,构建于 2021 年 6 月 24 日
运行时版本:11.0.8+10-b944.6842174 amd64
VM:N/A 的 OpenJDK 64 位服务器 VM
Windows 10 10.0
对于 MainActivity.java,这是代码。
package com.tutorial.android.mediaplayertest;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private MediaPlayer mediaPlayer;
private AudioManager audioManager;
private Button play, pause, decVolume, incVolume;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// I want my media player instantiated as soon as the app starts
mediaPlayer = MediaPlayer.create(this, R.raw.test);
// play button
play = findViewById(R.id.play_button);
play.setOnClickListener(view -> {
Toast.makeText(this, "Music Start", Toast.LENGTH_SHORT).show();
mediaPlayer.start();
});
// pause button
pause = findViewById(R.id.pause_button);
pause.setOnClickListener(view -> {
Toast.makeText(this, "Pause", Toast.LENGTH_SHORT).show();
mediaPlayer.pause();
});
audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
// volume down button
decVolume = findViewById(R.id.volume_down);
decVolume.setOnClickListener(view -> {
Toast.makeText(this, "Volume down", Toast.LENGTH_SHORT).show();
audioManager.adjustVolume(AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND);
});
// volume up button
incVolume = findViewById(R.id.volume_up);
incVolume.setOnClickListener(view -> {
Toast.makeText(this, "Volume up", Toast.LENGTH_SHORT).show();
audioManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
});
}
}
如果是activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:id="@+id/play_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Play" />
<Button
android:id="@+id/pause_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pause" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/volume_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-" />
<Button
android:layout_marginLeft="16dp"
android:id="@+id/volume_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+" />
</LinearLayout>
</LinearLayout>
我创建了一个音乐播放器应用程序,我想以编程方式设置音量 up/down。我想实现两个 Button
到 increase/decrease 音量并设置为媒体播放器。
Activity:
control = (ImageView) findViewById(R.id.control);
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
control.setOnClickListener(pausePlay);
control.setBackgroundResource(R.drawable.pause);
control id is my play and pause button :
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
if (playPause) {
control.setBackgroundResource(R.drawable.play);
if (mediaPlayer.isPlaying())
mediaPlayer.pause();
media.stop();
intialStage = false;
playPause = false;
} else {
control.setBackgroundResource(R.drawable.pause);
if (intialStage) {
new Player()
.execute("http://streaming.shoutcast.com/MUKILFMRADIO");
} else {
if (!mediaPlayer.isPlaying())
mediaPlayer.start();
}
playPause = true;
}
}
布局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/control1"
android:layout_margin="10dp"
android:layout_gravity="center"
android:background="@drawable/decrement"
android:layout_above="@+id/latestAddedSongs"
android:layout_alignEnd="@+id/musicArtistName" />
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/control"
android:layout_margin="10dp"
android:layout_gravity="center"
android:background="@drawable/play"
android:layout_above="@+id/latestAddedSongs"
android:layout_alignEnd="@+id/musicArtistName" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/control2"
android:layout_margin="10dp"
android:layout_gravity="center"
android:background="@drawable/increment"
android:layout_above="@+id/latestAddedSongs"
android:layout_alignEnd="@+id/musicArtistName" />
</LinearLayout>
试试下面的代码
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
seekbar.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int newVolume, boolean b) {
textview.setText("Media Volume : " + newVolume);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, newVolume, 0);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
为音频管理器创建对象
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
Button upButton = (Button) findViewById(R.id.upButton);
upButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//To increase media player volume
audioManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
}
});
Button downButton = (Button) findViewById(R.id.downButton);
downButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//To decrease media player volume
audioManager.adjustVolume(AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND);
}
});
上面的例子使用了Button标签
用于增大和减小音量 代码
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int action = event.getAction();
int keyCode = event.getKeyCode();
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
if (action == KeyEvent.ACTION_DOWN) {
audioManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
}
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (action == KeyEvent.ACTION_DOWN) {
audioManager.adjustVolume(AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND);
}
return true;
default:
return super.dispatchKeyEvent(event);
}
}
跟进jesu的解决方案,如果你想在服务中改变音量而不是Activity,替换:
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
与:
AudioManager audioManager;
audioManager = (AudioManager) YourServiceName.this.getSystemService(Context.AUDIO_SERVICE);
下面的代码效果很好
Android 中有几个可用的流可以用来管理音频
/** The audio stream for phone calls */
public static final int STREAM_VOICE_CALL = AudioSystem.STREAM_VOICE_CALL;
/** The audio stream for system sounds */
public static final int STREAM_SYSTEM = AudioSystem.STREAM_SYSTEM;
/** The audio stream for the phone ring */
public static final int STREAM_RING = AudioSystem.STREAM_RING;
/** The audio stream for music playback */
public static final int STREAM_MUSIC = AudioSystem.STREAM_MUSIC;
/** The audio stream for alarms */
public static final int STREAM_ALARM = AudioSystem.STREAM_ALARM;
/** The audio stream for notifications */
public static final int STREAM_NOTIFICATION = AudioSystem.STREAM_NOTIFICATION;
/** @hide The audio stream for phone calls when connected to bluetooth */
public static final int STREAM_BLUETOOTH_SCO = AudioSystem.STREAM_BLUETOOTH_SCO;
/** @hide The audio stream for enforced system sounds in certain countries (e.g camera in Japan) */
public static final int STREAM_SYSTEM_ENFORCED = AudioSystem.STREAM_SYSTEM_ENFORCED;
/** The audio stream for DTMF Tones */
public static final int STREAM_DTMF = AudioSystem.STREAM_DTMF;
/** @hide The audio stream for text to speech (TTS) */
public static final int STREAM_TTS = AudioSystem.STREAM_TTS;
根据您的需要,您可以在此处更改流 STREAM_MUSIC 示例:
您可以使用 AudioSytem 的反射获得常量值 class:
private int getStreamType(String streamName) {
final String streamSourceClassName = "android.media.AudioSystem";
int streamType = 0;
try {
streamType = (int) Class.forName(streamSourceClassName).getDeclaredField(streamName).get(null);
} catch (ClassNotFoundException | IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
return streamType;
}
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
seekbar.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int newVolume, boolean b) {
textview.setText("Media Volume : " + newVolume);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, newVolume, 0);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
如果你的类型是AudioManager.STREAM_MUSIC:使用这个代码,跟随phone音量按钮
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
audio.adjustStreamVolume(
AudioManager.STREAM_MUSIC,
AudioManager.ADJUST_RAISE,
AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
audio.adjustStreamVolume(
AudioManager.STREAM_MUSIC,
AudioManager.ADJUST_LOWER,
AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
return true;
default:
break;
}
return super.onKeyDown(keyCode, event);
}
AudioManager aManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
Button buttonUp= (Button) findViewById(R.id.upButton);
buttonUp.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
enter code here
//To increase media player volume
`enter code here`aManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
}
});
Button downButton = (Button) findViewById(R.id.downButton);
buttondown.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
aManager.adjustVolume(AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND);
}
});
此代码将在按下按钮 SES 时立即将音量设置为 100,而不会向用户反馈。
public void perform_actionSES(View v) {
Button buttonSES = (Button) findViewById(R.id.buttonSES);
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 100, 0);
}
各位编码员。我已尽力使代码尽可能简单。我希望这对某人有帮助。祝你有美好的一天!
我正在使用: Android Studio 4.2.2 构建 #AI-202.7660.26.42.7486908,构建于 2021 年 6 月 24 日 运行时版本:11.0.8+10-b944.6842174 amd64 VM:N/A 的 OpenJDK 64 位服务器 VM Windows 10 10.0
对于 MainActivity.java,这是代码。
package com.tutorial.android.mediaplayertest;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private MediaPlayer mediaPlayer;
private AudioManager audioManager;
private Button play, pause, decVolume, incVolume;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// I want my media player instantiated as soon as the app starts
mediaPlayer = MediaPlayer.create(this, R.raw.test);
// play button
play = findViewById(R.id.play_button);
play.setOnClickListener(view -> {
Toast.makeText(this, "Music Start", Toast.LENGTH_SHORT).show();
mediaPlayer.start();
});
// pause button
pause = findViewById(R.id.pause_button);
pause.setOnClickListener(view -> {
Toast.makeText(this, "Pause", Toast.LENGTH_SHORT).show();
mediaPlayer.pause();
});
audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
// volume down button
decVolume = findViewById(R.id.volume_down);
decVolume.setOnClickListener(view -> {
Toast.makeText(this, "Volume down", Toast.LENGTH_SHORT).show();
audioManager.adjustVolume(AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND);
});
// volume up button
incVolume = findViewById(R.id.volume_up);
incVolume.setOnClickListener(view -> {
Toast.makeText(this, "Volume up", Toast.LENGTH_SHORT).show();
audioManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
});
}
}
如果是activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:id="@+id/play_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Play" />
<Button
android:id="@+id/pause_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pause" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/volume_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-" />
<Button
android:layout_marginLeft="16dp"
android:id="@+id/volume_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+" />
</LinearLayout>
</LinearLayout>