Android L ActionBarActivity using Feinstein SldingMenu and AppCompat v21 turns off at the bottom of the screen

I use AppCompat v21 with the "NoActionBar" style and add an Action / Toolbar to onCreate .

SlidingMenu of Feinstein is also added, which causes the problem that the activity (and, therefore, the internal fragments) overlap with the Android navigation buttons (it is not fully shown, cropped at the bottom)

if i add:

 android:layout_marginBottom="48dp" 

everything is visible in the layout (of course).

In Android 4.4. everything is displayed correctly.

What am I missing on Android L using lib support?

SlidingMenu added to onCreate:

 super.onCreate(..) setContentView(..) menu = new SlidingMenu(this); menu.setMode(SlidingMenu.LEFT); menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW); menu.setMenu(R.layout.menu); menu.setBehindWidthRes(200dp); 

Decision:

The question is listed here https://github.com/jfeinstein10/SlidingMenu/issues/680 (including solution)

 Slding Menu to SLIDING_CONTENT OR: update the SlidingMenu source like mentioned in the link aboce 

The best solution:
(also works with Samsung devices on 5.0) - provided via

Adding the following lines to the SlidingMenu constructors worked for me. I did not need to make any other code changes.

 if(Build.VERSION.SDK_INT >= 21) setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) 
+4
android android-5.0-lollipop appcompat android-actionbaractivity jfeinstein
source share
6 answers

Adding the following lines to the SlidingMenu constructors worked for me. I did not need to make any other code changes.

 if(Build.VERSION.SDK_INT >= 21) setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); 
+8
source share

The question is listed here https://github.com/jfeinstein10/SlidingMenu/issues/680 (including solution)

  • Slding menu for SLIDING_CONTENT
  • OR: update SlidingMenu source as indicated in the aboce link
+2
source share

Try adding the android to the toolbar: minHeight = "? Attr / actionBarSize".

  <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 
0
source share

You have added a toolbar to your main LinearLayout , but you still use match_parent to height your FrameLayout container. Try filling in the remaining space of your LinearLayout, instead:

 <FrameLayout android:id="@+id/container" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="0dp" /> 
0
source share

If you are trying to use the Fenstein menu with the App App, you will probably get a problem with your menu. Your sliding menu will slide due to the bottom of your phone.

To fix this location

 YOUR-PROJECT/sliding-menu/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java 

Find

 int bottomPadding = insets.bottom; 

And replace it

 int bottomPadding = insets.bottom; if (Build.VERSION.SDK_INT >= 21) { Resources resources = getContent().getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { bottomPadding += resources.getDimensionPixelSize(resourceId); } } 

I have been diligently searching for this problem and the solution above worked for me.

0
source share

The following code worked for me: basically you always call setSlidingActionBarEnabled(false) , and then calculate and set the correct height of the root view according to the formula below, depending on whether you have a navigation bar or not.

 public class MyActivity extends SlidingActivity { ... @Override public void onCreate(Bundle savedInstanceState) { ... setSlidingActionBarEnabled(false); mBtmNavBarSize = getNavigationBarSize(this); mUsableScreenSize = getAppUsableScreenSize(this); mRootView = (View) findViewById(android.R.id.content); mRootView.post(new Runnable() { @Override public void run() { int[] hs = getStatusAndTitleBarHeight(); int nfh = mRootView.getHeight(); if (mBtmNavBarSize.y > 0) nfh = mUsableScreenSize.y - mBtmNavBarSize.y - hs[1]; ViewGroup.LayoutParams lp2 = mRootView.getLayoutParams(); lp2.height = nfh; mRootView.setLayoutParams(lp2); } }); ... public static Point getNavigationBarSize(Context context) { Point appUsableSize = getAppUsableScreenSize(context); Point realScreenSize = getRealScreenSize(context); // navigation bar on the right if (appUsableSize.x < realScreenSize.x) { return new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y); } // navigation bar at the bottom if (appUsableSize.y < realScreenSize.y) { return new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y); } // navigation bar is not present return new Point(); } // get usable screen size (real minus bottom navigation bar) public static Point getAppUsableScreenSize(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size; } public static Point getRealScreenSize(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= 17) { display.getRealSize(size); } else if (Build.VERSION.SDK_INT >= 14) { try { size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display); size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display); } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { } catch (NoSuchMethodException e) { } } return size; } private int[] getStatusAndTitleBarHeight() { Rect rectangle = new Rect(); Window window = getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rectangle); int statusBarHeight = rectangle.top; int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop(); int titleBarHeight = contentViewTop - statusBarHeight; return new int[]{statusBarHeight, titleBarHeight}; } ... } 
0
source share

All Articles