Viewpager desborda la pantalla dentro del diseño del coordinador
Estoy tratando de utilizar la biblioteca de soporte de diseño para implementar pestañas . El problema es que el viewpager superpone la barra de herramientas y tablayout cuando elimino el atributo
app:layout_behavior="@string/appbar_scrolling_view_behavior"
Del viewpager.
- Las devoluciones de llamadas CoordinatorLayout.Behavior no activan
- Menú del cajón secundario
- Deshabilitar tabulaciones en TabLayout
- El tema personalizado interfiere con el color de fondo del bocadillo
- SearchView es invisible con el parámetro collapseActionView desde la biblioteca de diseño 24.1
Viewpager superpone la barra de herramientas y tablayout
Y cuando agrego el atributo el viewpager desborda la pantalla.
Viewpager desborda la pantalla
Sólo necesito el viewpager para ocupar el espacio que queda después del tablayout y la barra de herramientas y no desbordar la pantalla …
Aquí está mi activity_main.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" > <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> <android.support.design.widget.TabLayout android:id="@+id/tablayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabGravity="fill" app:tabMode="fixed" /> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.CoordinatorLayout>
Y aquí está mi fragmento_1.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"> <TextView android:id="@+id/tV_item1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/activity_horizontal_margin" android:gravity="center" android:text="@string/tab1_q_persons" android:textSize="20sp" android:textStyle="bold" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="0 people" android:textSize="30sp" android:textStyle="bold" /> <ImageView android:id="@+id/iV_plus" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/iV_minus" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> <Button android:id="@+id/nextBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_gravity="end" android:background="@color/colorPrimary" android:elevation="12dp" android:text="@string/next" /> </RelativeLayout> </LinearLayout>
Cualquier ayuda será apreciada
- Panning google map en CoordinatorLayout hace que recyclerview se desplace en android design support library 23.0.1
- Elementos del menú de NavigationView con el contador a la derecha
- Eliminar etiquetas BottomNavigationView
- Stick vista en la parte inferior del fragmento de un viewpager dentro de la disposición del coordinador
- Android BottomSheet: Está buscando bajo la barra de herramientas
- El estilo TabLayout no puede resolver @ dimen / tab_max_width después de pasar a Android Design Support v23
- Cómo hacer que la cabecera de NavigationView sea pegajosa
- Forma de indicador de pestaña personalizada en Diseño de soporte de Widget TabLayout
Sé que parece tarde. Pero envío mi respuesta.
En activity_main.xml use RelativeLayout en lugar de CoordinatorLayout y puede eliminar AppBar. Para definir la barra de herramientas como AppBar puedes usar este código en MainActivity.java:
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar);
En fragment_1.xml utilice otro widget como CardView o ScrollView en lugar de LinearLayout o puede usar LinearLayout dentro del widget reemplazado.
Activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:layout_alignParentTop="true"/> <android.support.design.widget.TabLayout android:id="@+id/tablayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabGravity="fill" app:tabMode="fixed" android:layout_below="@id/toolbar"/> <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:layout_below="@id/tablayout" /> </RelativeLayout>
Fragment_1.xml
<android.support.v7.widget.CardView android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"> <TextView android:id="@+id/tV_item1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/activity_horizontal_margin" android:gravity="center" android:text="@string/tab1_q_persons" android:textSize="20sp" android:textStyle="bold" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="0 people" android:textSize="30sp" android:textStyle="bold" /> <ImageView android:id="@+id/iV_plus" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/iV_minus" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> <Button android:id="@+id/nextBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_gravity="end" android:background="@color/colorPrimary" android:elevation="12dp" android:text="@string/next" /> </RelativeLayout> </LinearLayout> </android.support.v7.widget.CardView>
Esta solución resolvió el mismo problema para mí.
Si realmente no necesita el diseño de AppBar, quítelo.
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> <android.support.design.widget.TabLayout android:id="@+id/tablayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabGravity="fill" app:tabMode="fixed" /> <android.support.v4.view.ViewPager android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" />
Este código funciona bien para mí.
- Bouncy Castle Keystore (BKS): java.io.IOException: Versión incorrecta del almacén de claves
- OnFling MotionEvent e1 null?