2017-07-27 2 views
0

Ich weiß, das scheint wie eine wiederholte Fragen, aber ich verstehe nicht, warum ich nicht Tablayout auf meinem ViewPager positionieren kann.Android Pager verbirgt Tab-Layout, wenn es oben positioniert ist

<RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="200dp"> 


      <android.support.design.widget.TabLayout 
       android:id="@+id/tl_ads" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       android:layout_alignParentBottom="true" 
       app:tabBackground="@drawable/tab_selector" 
       app:tabGravity="center" 
       app:tabIndicatorHeight="0dp" 
       app:tabMaxWidth="16dp" 
       app:tabPadding="2dp"/> 


      <android.support.v4.view.ViewPager 
       android:id="@+id/vp_ads" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@android:color/white" 
       android:elevation="2dp" 
       android:translationZ="2dp" 
       tools:targetApi="lollipop"/> 





     </RelativeLayout> 

Tablayout funktioniert gut, wenn ich die RelativeLayout mit Linearlayout ersetzen, außer das ist nicht das, was ich will.

Antwort

0

Versuchen Sie unten können Ihnen helfen. Fehler hier: android: layout_alignParentBottom = "true" enter image description here

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


<android.support.design.widget.TabLayout 
    android:id="@+id/tl_ads" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#9ad195" 
    android:minHeight="?attr/actionBarSize" /> 


<android.support.v4.view.ViewPager 
    android:id="@+id/vp_ads" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/tl_ads" 
    android:background="#cccccc" 
    android:elevation="2dp" 
    android:translationZ="2dp" 
    tools:targetApi="lollipop" /> 

+0

Danke, aber das ist nicht das, was ich wan't. Ich brauche das TabLayout, um es oben auf dem Viewpager anzuzeigen. Ich habe FrameLayout versucht und es hat auch nicht funktioniert. –

+0

antwort editiert check –

+0

Der Viewpager deckt in diesem Fall das TabLayout ab. –

Verwandte Themen