Android 11 拖动音量条会卡动画,如何在源码中修改
时间: 2024-02-01 15:15:21 浏览: 115
要修改 Android 11 的音量条动画卡顿问题,你需要下载 Android 11 源代码,并进入 `frameworks/base/packages/SystemUI/src/com/android/systemui/volume` 目录。然后,你需要找到 `VolumeDialogImpl.java` 文件,这是音量对话框的实现类。
在 `VolumeDialogImpl.java` 文件中,你需要找到 `updateWindowHeight()` 方法,这是用于更新音量对话框高度的方法。在该方法中,你需要将以下代码:
```
if (mExpandButtonAnimationRunning) {
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
} else {
mWindow.setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
WindowManager.LayoutParams.FLAG_DIM_BEHIND |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
}
```
替换为以下代码:
```
if (mExpandButtonAnimationRunning) {
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
} else {
mWindow.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
}
```
此更新将禁用音量对话框的窗口背景模糊效果,并且可以显著提高音量对话框的动画流畅度。
阅读全文