1

J'utilise la disposition du coordinateur lorsque je fais défiler vers le haut l'image s'est effondrée et le titre apparaît.titre de la barre d'outils afficher en bas

mais un problème est dans certains mobiles, il montre en bas.

enter image description here

ici est le code XML de mon ................................... .................................................. ..................

 <?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" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.donation.bhatt.donation.MainActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appBarLayout" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/image_size" 
     android:fitsSystemWindows="true" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsingToolbarLayout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:expandedTitleMarginEnd="64dp" 
      app:expandedTitleMarginStart="48dp" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <ImageView 
       android:id="@+id/main.backdrop" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:fitsSystemWindows="true" 
       android:src="@drawable/mainwindow" 
       app:layout_collapseMode="parallax" /> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/maintoolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:layout_collapseMode="parallax" 
       android:layout_gravity="top" 
       android:gravity="top" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

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

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


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/background" 
     android:elevation="4dp" 
     android:padding="15dp" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 


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

supprimer appbarlayout et vérifier –

Répondre

0

vous pouvez essayer cette

<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar_top" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:minHeight="?attr/actionBarSize" 
    app:layout_collapseMode="parallax" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" > 


<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:id="@+id/toolbar_title" /> 


</android.support.v7.widget.Toolbar> 
maintenant

définir le titre de votre barre d'outils comme celui-ci

Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar_top); 
TextView mTitle = (TextView) toolbarTop.findViewById(R.id.toolbar_title); 
mTitle.setText("title"); 
+0

il fonctionne merci pour votre aide :) – user6523976

+0

ma réputation est inférieure à 15 si StackOverflow ne me permet pas d'upvote. Désolé :( – user6523976

0

vous pourriez avoir besoin d'utiliser le drapeau expandedTitleGravity disponible pour CollapsingToolbarLayout pour définir la gravité de titre au centre horizontal

+0

i essayer cela, mais ne fonctionne toujours pas – user6523976