1
我在屏幕的右側視圖:MXPlayer如音量控制
<View
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:id="@+id/right_scroll">
</View>
我一直在使用迷上了滾動事件監聽到它:
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
Log.d("Gesture ", " onScroll");
if (e1.getY() < e2.getY()){
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
}
if(e1.getY() > e2.getY()) {
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
}
return false;
}
但這種狀況正在改變音量方式太快。有沒有什麼方法可以像MXPlayer一樣減慢音量變化?