I have created a DrawerLayout and also have an ImageView (a 'hamburger') that opens it when clicked.
My problem is that when using the following code, a lint error is shown in AndroidStudio: Must be one or more of: Gravity.LEFT, Gravity.RIGHT..., there is no Gravity.START in there.
ImageView openDrawerImageView = findViewById(R.id.open_drawer_image_icon);
openDrawerImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
drawerLayout.openDrawer(Gravity.START);
}
});
I looked for a while for an answer but did not find one. I decided to leave it for later since this is only a lint error and the app actually does work with Gravity.START.
Later I needed to close the drawer in some scenario so I used: drawerLayout.closeDrawer(START) then I used the autocomplete, and got the answer: GravityCompat
drawerLayout.closeDrawer(GravityCompat.START);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With