Fixes #1275 Set proper with of Navigation drawer in both orientations.
This commit is contained in:
neslihanturan 2018-03-16 13:04:11 +02:00 committed by GitHub
commit ce8c807348
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -88,8 +88,11 @@ public abstract class NavigationBaseActivity extends BaseActivity
private void setDrawerPaneWidth() {
ViewGroup.LayoutParams params = navigationView.getLayoutParams();
// set width to lowerBound of 80% of the screen size
params.width = (getResources().getDisplayMetrics().widthPixels * 70) / 100;
// set width to lowerBound of 70% of the screen size in portrait mode
// set width to lowerBound of 50% of the screen size in landscape mode
int percentageWidth = getResources().getInteger(R.integer.drawer_width);
params.width = (getResources().getDisplayMetrics().widthPixels * percentageWidth) / 100;
navigationView.setLayoutParams(params);
}

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="drawer_width">50</integer>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="drawer_width">70</integer>
</resources>