0

I'm using a viewpager to show fragments on my app, but I'm having some issues with the XML, I would like to fix my code because when I run the fragments, the viewpager doesn't show the the last part of the design, I'm using a listview on each fragment, and the last row is being cut. What do I need to change on my code to fix that?

Code:

<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:background="#c42542">


        <android.support.v7.widget.Toolbar
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_marginBottom="8dp"
            android:background="#d12240"
            app:layout_scrollFlags="scroll|enterAlways">

            <TextView
                android:id="@+id/tvTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/bar"
                android:layout_alignParentLeft="true"
                android:layout_gravity="left"
                android:text="Live rooms"
                android:textColor="#ffffff"
                android:textSize="18dp" />

            <ImageView
                android:layout_width="19dp"
                android:layout_height="19dp"
                android:layout_alignBottom="@+id/bar"
                android:layout_alignParentRight="true"
                android:layout_gravity="right"
                android:layout_marginRight="23dp"
                android:src="@mipmap/ic_share" />

            <ImageView
                android:layout_width="19dp"
                android:layout_height="19dp"
                android:layout_alignBottom="@+id/bar"
                android:layout_alignParentRight="true"
                android:layout_gravity="right"
                android:layout_marginRight="20dp"
                android:src="@mipmap/ic_search" />
        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            style="@style/MyCustomTabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|enterAlways"

            app:tabGravity="fill"
            app:tabMaxWidth="0dp"

            app:tabMode="fixed" />

    </android.support.design.widget.AppBarLayout>

    <!-- Scrollable View -->
    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>

Thank you.

Michael Jackson
  • 356
  • 3
  • 18

2 Answers2

0

Assign bottom margin to Listview.

<ListView
android:paddingBottom= "20dp"/>
HourGlass
  • 1,805
  • 1
  • 15
  • 29
0

Hey it seems this can occur when using ListView within the CoordinatorLayout, but you can fix it by simply changing it to a RecycleView. There's also a solution for Android 5.0+. Check out Sha's answer here for more info.

Community
  • 1
  • 1
Dave
  • 321
  • 1
  • 8