简体   繁体   English

TabLayout与ViewPager片段重叠

[英]TabLayout overlaps ViewPager Fragment

i habe an TabLayout in my Application where each Tab has its own Fragment. 我在应用程序中有一个TabLayout,其中每个选项卡都有其自己的片段。 But i cannot see the full content of my Fragment because the TabLayout overlaps the bottom of the fragment. 但是我看不到片段的全部内容,因为TabLayout与片段的底部重叠。 How can i solve the problem? 我该如何解决这个问题?

activity_main.xml activity_main.xml

<RelativeLayout
    android:id="@+id/main_layout"
    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="match_parent"
    tools:context=".activitys.MainActivity">

        <de.fhbielefeld.cardash.cardash.NonSwipeableViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorPrimary"
            app:tabMode="fixed"
            app:tabGravity="fill"
            android:layout_alignParentBottom="true"/>



</RelativeLayout>

fragment.xml fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <com.skobbler.ngx.map.SKMapViewHolder
        android:id="@+id/map_surface_holder"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_media_pause"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"/>

</RelativeLayout>

try this 尝试这个

<?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="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.union.experiment2.MainActivity"
tools:showIn="@layout/activity_main">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<de.fhbielefeld.cardash.cardash.NonSwipeableViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

<android.support.design.widget.TabLayout
    android:id="@+id/tab_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    app:tabMode="fixed"
    app:tabGravity="fill"
    android:layout_alignParentBottom="true"/>
<include
    layout="@layout/fragment"/>

Hope this will work make the tab layout in linear layout with orientation verticle and then just include the things u want to display in your layout 希望这可以使标签布局以具有方向顶点的线性布局,然后只包含您要在布局中显示的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM