0

Bonjour,Placer la mise en page sous la barre d'accès (comme dans Messenger)

Je suis en train de placer un (Cadre relatif? Linéaire?) La mise en page sous la barre d'accès et au-dessus du ViewPager, comme dans le Messenger Facebook App .

Comme « tous, MESSENGER, SMS » dans l'image ci-dessous:

enter image description here

Voici le code que j'ai essayé, mais il ne fonctionne pas, la mise en page n'apparaît pas sous la barre d'accès.

<?xml version="1.0" encoding="utf-8"?> 

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:layout_scrollFlags="scroll|enterAlways|snap" /> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      app:tabIndicatorColor="@color/fullWhite" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

    </android.support.design.widget.AppBarLayout> 

    <!-- This is the part I need to put between the AppBar and the content (ViewPager), but it is not shown --> 
    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/content_frame"> 
     <include layout="@layout/tous_messenger_sms"/> 
    </FrameLayout> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:background="@color/separator_color"/> 
</android.support.design.widget.CoordinatorLayout> 

Et voici mon "tous_messenger_sms" fichier de mise en page (le problème est probablement pas):

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:gravity="center_horizontal" 
     android:layout_marginLeft="16sp" 
     android:layout_marginRight="16sp"> 

    <Button 
     style="?android:textAppearanceSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="28sp" 
     android:id="@+id/tous_btn" 
     android:text="TOUS" 
     android:textColor="@color/colorPrimary" 
     android:layout_weight="1" 
     android:background="@drawable/button_shape_tous" 
     android:stateListAnimator="@null" /> 

    <Button 
     style="?android:textAppearanceSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="28sp" 
     android:id="@+id/messenger_btn" 
     android:text="MESSENGER" 
     android:textColor="@color/colorPrimary" 
     android:layout_weight="1" 
     android:background="@drawable/button_shape_messenger" 
     android:stateListAnimator="@null" /> 

    <Button 
     style="?android:textAppearanceSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="28sp" 
     android:id="@+id/sms_btn" 
     android:text="SMS" 
     android:textColor="@color/colorPrimary" 
     android:layout_weight="1" 
     android:background="@drawable/button_shape_sms" 
     android:stateListAnimator="@null" /> 
</LinearLayout> 
+0

Modifier la hauteur de mise en page de cadre et pager vue de "wrap_content". Quelle est la sortie que vous obtenez pour le code ci-dessus ?? – SaravInfern

+0

Cela ne change rien (merci pour la réponse)! La sortie est facile: le FrameLayout n'est pas montré, comme s'il n'existait pas x) –

+1

Enveloppant viewpager et tour_messenger_sms dans une disposition relative ou linéaire et en le gardant à la place de viewpager ?? Je pense que cela fonctionne – Ramesh

Répondre

0

Essayez cette mise en page

<?xml version="1.0" encoding="utf-8"?> 

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:layout_scrollFlags="scroll|enterAlways|snap" /> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      app:tabIndicatorColor="@color/fullWhite" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

    </android.support.design.widget.AppBarLayout> 

    <!-- This is the part I need to put between the AppBar and the content (ViewPager), but it is not shown --> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/content_frame"> 
      <include layout="@layout/tous_messenger_sms"/> 
     </FrameLayout> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/viewpager" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/separator_color" /> 

    </LinearLayout> 

</android.support.design.widget.CoordinatorLayout> 
+0

Cela fonctionne, merci! –