2017-07-27 2 views
0

Je sais que cela semble être une question répétée, mais je ne comprends pas pourquoi je ne peux pas placer Tablayout au-dessus de mon ViewPager.téléavertisseur Android cache mise en page Tab si elle est placée sur le dessus de celui-ci

<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 fonctionne très bien si je remplace le RelativeLayout avec LinearLayout sauf ce n'est pas ce que je veux.

Répondre

0

Essayez ci-dessous peut vous aider. erreur ici: 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

Merci, mais ce n'est pas ce que je wan't. J'ai besoin de la TabLayout pour montrer au-dessus du viewpager. J'ai essayé FrameLayout et cela n'a pas fonctionné aussi. –

+0

réponse chèque modifié –

+0

Le Viewpager couvre la TabLayout dans ce cas. –