Android DrawerLayout - openDrawer with Gravity.Start creates a lint error "Must be one or more of..."
Asked Answered
A

1

7

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);
    }
});
Audette answered 24/10, 2018 at 16:21 Comment(0)
A
18

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);
Audette answered 24/10, 2018 at 16:21 Comment(1)
looks like a lint bug (the message should refer GravityCompat instead of Gravity)Wamsley

© 2022 - 2024 — McMap. All rights reserved.