Android L ActionBarActivity con Feinstein SldingMenu y AppCompat v21 se corta en la parte inferior de la pantalla
Estoy usando AppCompat v21
con el estilo "NoActionBar" y agregar una acción / barra de herramientas en onCreate
.
También se agrega un SlidingMenu de Feinstein y eso causa el problema de que la Actividad (y por lo tanto los Fragmentos internos) se superponen con los botones de navegación de Android (no se muestra completamente, se corta en la parte inferior)
- SearchView en AppCompat distorsiona el icono
- Viendo el mensaje en los registros: "app: theme is deprecated"?
- No se pudo mostrar elementos con la biblioteca AppCompat
- Usar AppCompat 'layout_behavior' con '@ string / appbar_scrolling_view_behavior' lanza la excepción
- Diseño de material android con AppCompatActivity
Si agrego
android:layout_marginBottom="48dp"
En el diseño todo es visible (por supuesto).
En Android 4.4. Todo se muestra correctamente.
¿Qué me falta en Android L usando la lib de soporte?
SlidingMenu añadido en 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);
Solución:
El problema se indica aquí https://github.com/jfeinstein10/SlidingMenu/issues/680 (incluida la solución)
Slding Menu to SLIDING_CONTENT OR: update the SlidingMenu source like mentioned in the link aboce
Mejor solución:
(También trabajando con dispositivos Samsung en 5.0) – proporcionado por withaay
Añadir las siguientes líneas a los constructores de SlidingMenu ha funcionado para mí. No tuve que hacer ningún otro cambio de código.
if(Build.VERSION.SDK_INT >= 21) setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
- Cómo obtener Lollipop "hamburger" como icono de cajón en la aplicación Fragmento estándar (sin utilizar AppCompat)?
- Mi FloatingActionButton tiene algunas líneas extrañas que salen de él en 4.4 y menor
- Establecer ActionBar Tabs en la parte inferior de ActionBarActivity
- La barra de estado se vuelve blanca y no muestra contenido detrás de ella
- Spinner: infla la excepción al usar AppCompat
- Excepción java.lang.NoClassDefFoundError: android.support.v7.appcompat.R $ styleable
- Transición más suave de la actividad de pantalla completa con ActionBarSherlock
- El botón de acción flotante no es visible al desplazarse después de actualizar Google Support & Design Library
Añadir las siguientes líneas a los constructores de SlidingMenu ha funcionado para mí. No tuve que hacer ningún otro cambio de código.
if(Build.VERSION.SDK_INT >= 21) setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
El problema se indica aquí https://github.com/jfeinstein10/SlidingMenu/issues/680 (incluida la solución)
- Menú Slding a SLIDING_CONTENT
- O bien: actualizar la fuente de SlidingMenu como se menciona en el enlace aboce
Trate de añadir android: minHeight = "? Attr / actionBarSize" a su barra de herramientas.
<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"/>
Has añadido la barra de herramientas en tu LinearLayout
principal, pero todavía estás usando match_parent
para la altura de tu contenedor FrameLayout
. Intente llenar el espacio restante de su LinearLayout en su lugar:
<FrameLayout android:id="@+id/container" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="0dp" />
Si está intentando utilizar Fenstein Menu con App Compat probablemente obtendrá un problema con su menú slding. El menú deslizante se deslizará por detrás de la barra inferior del teléfono.
Para corregir esta localización
YOUR-PROJECT/sliding-menu/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java
Encontrar
int bottomPadding = insets.bottom;
Y reemplácelo
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); } }
Busqué mucho este problema y la solución anterior funcionó para mí.
El siguiente código funcionó para mí: básicamente, usted siempre llama a setSlidingActionBarEnabled(false)
y luego calcula y establece la altura correcta de su vista raíz según la siguiente fórmula, dependiendo del hecho de que tenga una barra de navegación o no.
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}; } ... }
- Android: actividad ha filtrado ventana debido al diálogo de progreso?
- "No pudo encontrar el error com_facebook_android.apk" al ejecutar el proyecto de Android