在frameworks\base\packages\SystemUI\res\layout-sw600dp\status_bar.xml中添加如下两个按钮:
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/sound1"
android:layout_width="80dp"
android:layout_height="match_parent"
android:src="@drawable/soundleft"
systemui:keyCode="25"
android:layout_weight="0"
systemui:glowBackground="@drawable/ic_sysbar_highlight"
android:contentDescription="@string/accessibility_Volume_reduction"
/>
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/sound2"
android:layout_width="80dp"
android:layout_height="match_parent"
android:src="@drawable/soundright"
systemui:keyCode="24"
android:layout_weight="0"
systemui:glowBackground="@drawable/ic_sysbar_highlight"
android:contentDescription="@string/accessibility_Volume_increase"
/>
添加完即可,它的实现函数系统已经做好,具体类参考KeyButtonView.java文件。