Android Button below a ViewPager with no fixed size

1

I'm creating a layout where I need a button below ViewPager, in this layout I also loads tabs, as in the image below:

WhathappensisthatIcannotleavethiswaywithoutsettingtheViewPagersize,itfollowsthexmlofthelayout.

<?xmlversion="1.0" encoding="utf-8"?>

<android.support.design.widget.TabLayout
    android:id="@+id/tlTabs"
    app:tabGravity="fill"
    app:tabIndicatorColor="@color/orange"
    app:tabMode="fixed"
    app:tabSelectedTextColor="@color/orange"
    app:tabTextColor="@color/white"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/azulForte">
</android.support.design.widget.TabLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/vpPager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>

<Button
    android:layout_width="wrap_content"
    android:layout_height="67dp"
    android:text="New Button"
    android:id="@+id/button"
    android:layout_gravity="center_horizontal"/>

The way I did the button is not displayed, how can I fix this? Thank you.

EDITED

MainActivity Layout

<LinearLayout
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:fitsSystemWindows="true"
android:orientation="vertical">

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/orange"
    android:id="@+id/toolbar"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:title="Drawer With Swipe Tabs" />

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:id="@+id/drawerLayout">

    <FrameLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/containerView">
    </FrameLayout>

    <android.support.design.widget.NavigationView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:id="@+id/shitstuff"
        app:itemTextColor="@color/black"
        app:menu="@menu/drawermenu"
        android:layout_marginTop="-24dp"
        />

</android.support.v4.widget.DrawerLayout>

Layout Fragment Tab

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            tools:context=".fragments.TabFragment">

<android.support.design.widget.TabLayout
    android:id="@+id/tlTabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/azulForte"
    app:tabGravity="fill"
    app:tabIndicatorColor="@color/orange"
    app:tabMode="scrollable"
    app:tabSelectedTextColor="@color/orange"
    app:tabTextColor="@color/white">
</android.support.design.widget.TabLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/vpPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</android.support.v4.view.ViewPager>

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="67dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_gravity="center_horizontal"
    android:text="New Button"/>
</RelativeLayout>
    
asked by anonymous 10.08.2016 / 20:13

1 answer

1

Talk Renan,

It's probably not showing because you're using LinearLayout in your screen layout.

Try changing it to RelativeLayout that it will appear.

Note: If not, you'd better post the whole code of your XML.

Hugs.

    
10.08.2016 / 20:24