android12 媒体音量条占满音量条dialog产生的触摸问题

android12 隐藏铃声和设置icon等,媒体音量条占满音量条dialog,产生的触摸问题:

横屏时只能触摸右边区域; 竖屏时最上面有一块区域不能触摸
否则会触发action_outside,音量条dismiss

  • mDialog.setContentView(R.layout.volume_dialog); //音量条整体
  • mDialogView = mDialog.findViewById(R.id.volume_dialog); // 触摸修改媒体音量
  • mDialogRowsView = mDialog.findViewById(R.id.volume_dialog_rows); //音量的一格
 private void setupRingerDrawer() {
    
    
 ***
 // In portrait, add padding to the bottom to account for the height of the open ringer
        // drawer.
        if (!isLandscape()) {
    
    
            mDialogView.setPadding(
                    mDialogView.getPaddingLeft(),
                    mDialogView.getPaddingTop(),
                    mDialogView.getPaddingRight(),
                    mDialogView.getPaddingBottom() + getRingerDrawerOpenExtraSize());  //竖屏加padding到底部
        } else {
    
    
            mDialogView.setPadding(
                    mDialogView.getPaddingLeft() + getRingerDrawerOpenExtraSize(),  //横屏时加paddding到左边
                    mDialogView.getPaddingTop(),
                    mDialogView.getPaddingRight(),
                    mDialogView.getPaddingBottom());
        }
}


    private void unionViewBoundstoTouchableRegion(final View view) {
    
    
     	...
        // The ringer and rows container has extra height at the top to fit the expanded ringer
        // drawer. This area should not be touchable unless the ringer drawer is open.
//翻译:振铃器和行容器在顶部有额外的高度,以适应扩展的振铃器//抽屉。这个区域不应该被触摸,除非铃声抽屉是打开的。
        if (view == mTopContainer && !mIsRingerDrawerOpen) {
    
    
            if (!isLandscape()) {
    
    
                y += getRingerDrawerOpenExtraSize();
            } else {
    
    
                x += getRingerDrawerOpenExtraSize();
            }
        }

 	...
    }

diff:
	/**
   	 * 隐藏了铃声等其他音量条,所以需要去除掉它们的padding 使得媒体音量条占满音量条区域
     * Return the size of the 1-2 extra ringer options that are made visible when the ringer drawer
     * is opened. The drawer options are square so this can be used for height calculations (when in
     * portrait, and the drawer opens upward) or for width (when opening sideways in landscape).
     */
    private int getRingerDrawerOpenExtraSize() {
    
    
        // return (mRingerCount - 1) * mRingerDrawerItemSize;
        return 0;
    }

猜你喜欢

转载自blog.csdn.net/qq_44256828/article/details/129637835