1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 安卓游戏时禁止状态栏下拉 如何在Android中禁用通知栏下拉菜单?

安卓游戏时禁止状态栏下拉 如何在Android中禁用通知栏下拉菜单?

时间:2019-05-12 01:55:45

相关推荐

安卓游戏时禁止状态栏下拉 如何在Android中禁用通知栏下拉菜单?

I am building a new lock screen for Android, but I am unable to lock the notification bar from pulling it down.

I want to disable the notification bar pull-down.

解决方案private void disablePullNotificationTouch() {

WindowManager manager = ((WindowManager) getApplicationContext()

.getSystemService(Context.WINDOW_SERVICE));

WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();

localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;

localLayoutParams.gravity = Gravity.TOP;

localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |

// this is to enable the notification to recieve touch events

WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |

// Draws over status bar

WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;

localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;

localLayoutParams.height = (int) (25 * getResources()

.getDisplayMetrics().scaledDensity);

localLayoutParams.format = PixelFormat.RGBX_8888;

customViewGroup view = new customViewGroup(this);

manager.addView(view, localLayoutParams);

}

//Add this class in your project

public class customViewGroup extends ViewGroup {

public customViewGroup(Context context) {

super(context);

}

@Override

protected void onLayout(boolean changed, int l, int t, int r, int b) {

}

@Override

public boolean onInterceptTouchEvent(MotionEvent ev) {

Log.v("customViewGroup", "**********Intercepted");

return true;

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。