Max navigation drawer width

This commit is contained in:
str4d
2014-11-17 01:03:55 +00:00
parent d3e06e36e8
commit 765bfd090d
3 changed files with 7 additions and 3 deletions

View File

@@ -101,12 +101,13 @@ public class EmailListActivity extends ActionBarActivity implements
// Set the drawer width per Material design spec
// http://www.google.com/design/spec/layout/structure.html#structure-side-nav-1
// Mobile: side nav width = screen width - app bar height
// Desktop: Max width for left nav is 400 dp. Not handled yet.
// Mobile: side nav width = min(screen width - app bar height, 320dp)
// Desktop: side nav width = min(screen width - app bar height, 400dp)
int maxWidth = getResources().getDimensionPixelSize(R.dimen.nav_max_width);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
DrawerLayout.LayoutParams lp = (DrawerLayout.LayoutParams) mDrawerOuter.getLayoutParams();
lp.width = dm.widthPixels - toolbar.getLayoutParams().height;
lp.width = Math.min(dm.widthPixels - toolbar.getLayoutParams().height, maxWidth);
// Set the list of folders
// TODO: This is slow, needs a loader

View File

@@ -5,4 +5,6 @@
screen margins) for sw600dp devices (e.g. 7" tablets) here.
-->
<dimen name="nav_max_width">400dp</dimen>
</resources>

View File

@@ -3,6 +3,7 @@
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="nav_max_width">320dp</dimen>
<dimen name="nav_horizontal_margin">16dp</dimen>
<dimen name="nav_entry_height">48dp</dimen>