我正在尝试以编程方式将 NavigationDrawer 添加到我的活动中,但是当添加它时,我无法与屏幕的其余部分进行交互,例如,按钮不是可点击的。添加 de NavigationDrawer 的方法是这样的:
//The activity view
final ViewGroup viewActvity = (ViewGroup) this.findViewById(android.R.id.content);
//The custom view to show in the NavigationDrawer
LinearLayout menu = new LinearLayout(this);
//The DrawerLayout
DrawerLayout drawerLayout = new android.support.v4.widget.DrawerLayout(this);
float width = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 280, getResources().getDisplayMetrics());
DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams((int) width, LinearLayout.LayoutParams.MATCH_PARENT);
lp.gravity = Gravity.START;
LinearLayout drawerPanel = new LinearLayout(this);
drawerPanel.setGravity(Gravity.START);
drawerPanel.setClickable(true);
drawerPanel.setLayoutParams(lp);
drawerPanel.addView(menu, lp);
drawerPanel.setOrientation(LinearLayout.VERTICAL);
drawerLayout.addView(drawerPanel, lp);
viewActvity.addView(drawerLayout);
任何想法?谢谢