0

Je suis confronté au problème avec le ActionBar dans le fragment lors du défilement. Il prend des espaces supplémentaires à partir du haut et le texte qui est dans le haut de l'écran se chevauche. Je suis confus où est le problème et suis resté coincé ici pour plus de temps. Pouvez-vous m'aider à me débarrasser de ces problèmes.Problème avec l'ActionBar du fragment

activity_home.xml

<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/coordinate" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     android:visibility="visible"> 

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/appBar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/AppTheme.AppBarOverlay" 
      android:visibility="visible"> 

      <android.support.design.widget.CollapsingToolbarLayout 
       android:id="@+id/htab_collapse_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@color/tab_selected" 
       android:fitsSystemWindows="true" 
       app:contentScrim="?attr/colorPrimary" 
       app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

       <LinearLayout 
        android:id="@+id/layoutLinear" 
        android:layout_width="match_parent" 
        android:layout_height="175dp" 
        android:background="@color/tab_selected" 
        android:fitsSystemWindows="true" 
        android:gravity="center" 
        android:orientation="vertical" 
        android:visibility="visible" 
        app:layout_collapseMode="parallax"> 

        <com.traveller.widget.TextViewOsaka 
         android:id="@+id/tvHeaderTitle" 

         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:gravity="center" 
         android:layout_marginLeft="@dimen/scale_20dp" 
         android:layout_marginRight="@dimen/scale_20dp" 
         android:layout_marginTop="@dimen/scale_30dp" 
         android:singleLine="true" 
         android:textColor="@color/white" 
         android:textSize="17sp" /> 

        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="@dimen/scale_20dp" 
         android:layout_marginRight="@dimen/scale_20dp" 
         android:layout_marginTop="@dimen/scale_5dp" 
         android:background="@drawable/bg_box__offwhite" 
         android:gravity="center_vertical" 
         android:orientation="horizontal" 
         android:padding="@dimen/scale_10dp"> 


         <AutoCompleteTextView 

          android:id="@+id/edSearch" 
          android:layout_width="0dp" 
          android:layout_height="wrap_content" 
          android:layout_weight="1" 
          android:background="@android:color/transparent" 
          android:hint="Search for an outlet, location or category" 
          android:imeOptions="actionSearch" 
          android:singleLine="true" 
          android:textColor="@color/light_grey" 
          android:completionThreshold="1" 
          android:textColorHint="@color/light_grey" 
          android:paddingLeft="10dp" 
          android:textSize="14sp" /> 


         <android.support.v7.widget.AppCompatImageView 
          android:id="@+id/ivSearch" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:padding="@dimen/scale_5dp" 
          android:src="@drawable/ic_search" /> 

        </LinearLayout> 
       </LinearLayout> 

       <android.support.v7.widget.Toolbar 
        android:id="@+id/toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="?attr/actionBarSize" 
        android:background="@color/tab_selected" 
        android:gravity="top" 
        android:minHeight="?attr/actionBarSize" 
        app:layout_collapseMode="pin" 
        app:popupTheme="@style/AppTheme.PopupOverlay" 
        app:theme="@style/AppTheme" 
        app:titleMarginTop="13dp"> 

        <FrameLayout 
         android:id="@+id/frame_home" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:background="@color/tab_selected" 
         android:visibility="gone"> 

         <com.traveller.widget.TextViewOsaka 
          android:id="@+id/tvCurrentTemp" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center_vertical" 
          android:drawableLeft="@drawable/ic_weather" 
          android:drawablePadding="@dimen/scale_5dp" 
          android:gravity="center" 
          android:textColor="@color/white" 
          android:textSize="17sp" /> 

         <Spinner 
          android:id="@+id/spnCountry" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:layout_marginLeft="20dp" 
          android:background="@drawable/bg_box__onwhite" 
          android:gravity="center" 
          android:textColor="@color/white" /> 

        </FrameLayout> 

        <FrameLayout 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:visibility="visible"> 

         <ImageView 
          android:id="@+id/ivBack" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="left|center_vertical" 
          android:padding="@dimen/scale_10dp" 
          android:src="@drawable/ic_back_header" /> 

         <ImageView 
          android:id="@+id/img_logo" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:layout_marginLeft="@dimen/scale_20dp" 
          android:src="@drawable/ic_clock" /> 
        </FrameLayout> 

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

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

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

     <FrameLayout 
      android:id="@+id/frame_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

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

    <fragment 
     android:id="@+id/navigation_drawer" 
     android:name="com.traveller.fragment.NavigationDrawerFragment" 
     android:layout_width="@dimen/scale_300dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="end" 
     tools:layout="@layout/fragment_navigation_drawer" /> 

</android.support.v4.widget.DrawerLayout> 

Mais lorsque l'on travaille avec les activités il n'y a pas de problème.

Merci

Screenshot.jpg

Screenshot2.jpg

Répondre

0

J'ai eu le même problème i résolu en ajoutant l'action hauteur de la barre comme marge supérieure dans le porte-fragment

<fragment 
    android:marginTop="?attr/actionBarSize" 
    android:id="@+id/navigation_drawer" 
    android:name="com.traveller.fragment.NavigationDrawerFragment" 
    android:layout_width="@dimen/scale_300dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="end" 
    tools:layout="@layout/fragment_navigation_drawer" /> 
+0

Je reçois le même résultat en spécifiant android: layout_marginTop = "? attr/actionBarSize" –

+0

J'ai joint ano image de la page –