How to stop Android navigation drawer from opening automatically?

后端 未结 1 1952
清酒与你
清酒与你 2021-01-23 03:33

How to stop the navigation drawer in my Android app from opening automatically?

It used to work fine. Out of sight at first and able to be swiped into visibility. But I

相关标签:
1条回答
  • 2021-01-23 04:06

    It's not that your drawer is opening automatically. It's that the DrawerLayout isn't finding a View to use as the drawer, so both of its direct child Views are filling it. The LinearLayout meant to be the drawer, being listed last, is covering the content View, so it just appears that the drawer is open.

    DrawerLayout determines which Views to use as drawers by looking through its direct children for ones with a horizontal layout_gravity setting; i.e., left/right, or start/end. You want this attribute set on the LinearLayout, since it's now acting as the drawer. In your main layout, simply move android:layout_gravity="left" from the ListView to the LinearLayout.

    0 讨论(0)
提交回复
热议问题