Sets the proper width to Navigation drawer in portrait and landscape mode.

Fixes #1275
This commit is contained in:
knightshade 2018-03-11 10:52:09 +05:30
parent 3bd02704b5
commit 4861c4dfa3
3 changed files with 13 additions and 2 deletions

View file

@ -88,8 +88,11 @@ public abstract class NavigationBaseActivity extends BaseActivity
private void setDrawerPaneWidth() { private void setDrawerPaneWidth() {
ViewGroup.LayoutParams params = navigationView.getLayoutParams(); ViewGroup.LayoutParams params = navigationView.getLayoutParams();
// set width to lowerBound of 80% of the screen size // set width to lowerBound of 70% of the screen size in portrait mode
params.width = (getResources().getDisplayMetrics().widthPixels * 70) / 100; // 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); 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>