By using the DrawerLayout I discovered, that a click on the Drawer View is not handled by itself, if no View is clicked. The Content View of the Drawer will handle that click event insteed.
To be more specific: The DrawerLayout has 2 childs the Content View and the Drawer View, which can be pulled frome the side.
My Content View is a ListView and my Drawer View is an LinearLayout containing an Edittext. The Drawer View is set to fill the whole View. Now a click on the blank Drawer View, so no click on the EditText, will be outreached to the underlaying Content View and an item of my ListView will be clicked.
What is the best way to prevent this?
At the moment I have this:
LinearLayout drawerView = (LinearLayout)findViewById(R.id.input_drawer);
drawerView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Do nothing just catch the click
}
});
The LinearLayout is my ViewGroup for the Drawer View, which is defined in XML. Because the DrawerListener has no callback for click events I tried this, and it works to prevent the click on the underlaying ListView. But this doesn't feel great.
UPDATE:
How i said, the LinearLayout height in the DrawerView is set to "match_parent" to fill the whole Drawer View. If I set the height to "wrap_content" the Drawer View will not be set from the upper display boarder to the lower boarder, which is quite ugly. So, the Drawer View is not defined to set the whole screen height.
With that said, the ViewGroup (LinearLayout) is responsible for the Drawer View's height. The Drawer View itself has no Listener at all to catch clicks, if no View in the ViewGroup is clicked. So in this case my attempt to define a onClickListener for the ViewGroup is the only way to prevent the click on the underlaying Content View.
If I'm wrong, because I surely could miss something, please correct me.