I want to use tab bar at bottom ... this is my Xml file ... Its shown in bottom but its overlapping on viewpager's fragment
<?xml version="1.0" encoding="utf-8"?>
<include layout="@layout/app_bar" />
<RelativeLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorMiddarkGray"
app:tabBackground="@drawable/tab_color_selector" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_above="@id/sliding_tabs"
android:layout_alignParentTop="true" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:itemBackground="@color/colorMiddarkGray">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/nav_view_header"
layout="@layout/nav_header_main" />
<include layout="@layout/nav_menu" />
</LinearLayout>
</android.support.design.widget.NavigationView>
But output dont show in full.. my viewpager not getting bottom padding or margin ... I want to show bottom tab layout with view pager
I changed RelativeLayout
to LinearLayout
because layout_weight
only works with LinearLayout
children and then changed the order to display ViewPager
followed by TabLayout
. Try this:
<LinearLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_above="@id/sliding_tabs"
android:layout_alignParentTop="true" />
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorMiddarkGray"
app:tabBackground="@drawable/tab_color_selector" />
</LinearLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.