标签:
public void setDrawerLeftEdgeSize(DrawerLayout drawerLayout, float displayWidthPercentage) { if (drawerLayout == null) return; try { // find ViewDragHelper and set it accessible Field leftDraggerField = drawerLayout.getClass().getDeclaredField("mLeftDragger"); leftDraggerField.setAccessible(true); ViewDragHelper leftDragger = (ViewDragHelper) leftDraggerField.get(drawerLayout); // find edgesize and set is accessible Field edgeSizeField = leftDragger.getClass().getDeclaredField("mEdgeSize"); edgeSizeField.setAccessible(true); int edgeSize = edgeSizeField.getInt(leftDragger); // set new edgesize // Point displaySize = new Point(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); edgeSizeField.setInt(leftDragger, Math.max(edgeSize, (int) (dm.widthPixels * displayWidthPercentage))); } catch (Exception e) { // ignore } }
标签:
原文地址:http://www.cnblogs.com/niray/p/5458706.html