2016-09-06 7 views
0

は、私は、これは私のXMLファイルです...下部のタブバーを使用する をしたい... その下に示されているが、viewpagerの断片上にその重複下部にタブレイアウトのあるページャは機能しませんか?

<?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> 

しかし、出力は完全に表示されません。 私のビューページは下のパディングまたは余白を得られません。 ビューページャーで下のタブレイアウトを表示したい

enter image description here

答えて

1

layout_weightだけLinearLayout子供たちと一緒に働き、その後TabLayout続いViewPagerを表示するために変更されたため、私はLinearLayoutRelativeLayoutを変更しました。試してみてください:

<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> 
関連する問題