0

我面對一些Android設計中的UI設計問題,我一直在尋找Stackoverflow其他來源,試圖找出失蹤的東西,但直到現在我一直沒有運氣。在TabBar佈局上摺疊工具欄文本

我認爲如果我用截圖解釋這個問題會更容易和更好。我面臨的問題是,我在Collapsing工具欄佈局(AppBarLayout內)上有一個文本,當您縮小AppBarLayout時,有一個短暫的時刻,文本位於TabLayout後面,導致TabBar的標題位於摺疊工具欄的標題:S。

這是我的結構:

enter image description here

這是當你打開活動(在這一點上它是完美的)

enter image description here

具有外觀,但事情是當您開始向上滾動並且摺疊工具欄開始縮小時,摺疊工具欄上的文本恰好位於TabBar佈局的標題後面

enter image description here

正如我以前說過這只是發生在這個點,因爲如果繼續萎縮則再次開始正常行動(改變內到工具欄的顏色一切)

enter image description here

最後,再次到達最終位置用正確的行爲

enter image description here

我想我錯過了一些東西,也許這是一件小事,但我無法弄清楚是哪一個。

這是佈局內的代碼:

<?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:id="@+id/ntx_coordinator" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fitsSystemWindows="true" 

      app:collapsedTitleGravity="left" 
      app:collapsedTitleTextAppearance="@style/CollapsingTextAppearance.Expanded" 
      app:contentScrim="@color/netex_color_pink" 
      app:expandedTitleGravity="center|top" 
      app:expandedTitleMarginEnd="64dp" 
      app:expandedTitleMarginStart="48dp" 
      app:expandedTitleMarginTop="16dip" 
      app:expandedTitleTextAppearance="@style/CollapsingTextAppearance.Collapsed" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 


      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@color/netex_color_gray_bg" 
       app:layout_collapseMode="parallax" 
       tools:background="@color/yellow"> 

       <com.facebook.drawee.view.SimpleDraweeView 
        android:id="@+id/ntx_background" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        app:actualImageScaleType="centerCrop" 
        app:backgroundImage="@drawable/vector_container_plan_header" 
        app:layout_collapseMode="parallax" 
        app:placeholderImage="@drawable/vector_container_plan_header" 
        app:placeholderImageScaleType="centerCrop" /> 

       <com.facebook.drawee.view.SimpleDraweeView 
        android:id="@+id/ntx_profile_avatar" 
        android:layout_width="@dimen/netex_drawer_avatar_size_profile" 
        android:layout_height="@dimen/netex_drawer_avatar_size_profile" 
        android:layout_alignParentTop="true" 
        android:layout_centerHorizontal="true" 
        android:layout_gravity="center_horizontal" 
        android:layout_marginBottom="0dp" 
        android:layout_marginTop="80dip" 
        app:placeholderImage="@drawable/ic_user_64" 
        app:placeholderImageScaleType="centerCrop" 
        app:roundingBorderColor="@color/netex_color_gray_bg" 
        app:roundingBorderWidth="2dp" 
        tools:background="@color/green" 
        tools:placeholder="@drawable/plan_placeholder" /> 

       <TextView 
        android:id="@+id/txt_title" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/ntx_profile_avatar" 
        android:paddingBottom="@dimen/netex_padding_medium" 
        android:paddingTop="@dimen/netex_padding_medium" 
        tools:text="iogjwerogi jioerwjgoiwerj oerwjgoiewrjgoijio jreog jojwer oj oijgj owerjgo iwjeroigj wroij owejoig wjeroigjeoi jioerj goi jeoigjwreoi rewogjtioryure igjiorthj iujeriheritohirthn irthsnbjrthkjg tmkhntjb l kxcjhjoigsdrjoi hjdriugjiothjoiuhjoidtjohjoih jogjhdjoijdojioi" /> 

       <Button 
        android:id="@+id/btn_enrol" 
        android:layout_width="wrap_content" 
        android:layout_height="36dip" 
        android:layout_below="@+id/txt_title" 
        android:layout_centerHorizontal="true" 
        android:layout_marginBottom="16dip" 
        tools:text="RESQUEST ENROLLEMNT" /> 

       <View 
        android:layout_width="match_parent" 
        android:layout_height="70dp" 
        android:layout_below="@+id/btn_enrol" 
        tools:background="@color/azure" /> 

      </RelativeLayout> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/ntx_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="96dp" 
       android:gravity="top" 
       android:minHeight="?attr/actionBarSize" 
       app:layout_collapseMode="pin" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> 

       <TextView 
        android:id="@+id/ntx_toolbar_title" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:ellipsize="end" 
        android:lines="1" 
        android:singleLine="true" /> 

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

      <com.netexlearning.mobile.ntxlearningapp.ntxviewkit.ntxviews.NTXTabLayout 
       android:id="@+id/ntx_tabs" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:layout_gravity="bottom" 
       app:tabGravity="center" 
       app:tabIndicatorColor="@color/white" 
       app:tabMaxWidth="0dp" 
       app:tabMode="fixed" 
       app:tabTextColor="@color/white" /> 

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


    <com.netexlearning.mobile.ntxlearningapp.helpers.NTXViewPager 
     android:id="@+id/ntx_viewPager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/netex_color_gray_row" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     tools:background="@color/red" /> 

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

如果任何人都可以點我到正確的方向:)

非常感謝你提前

回答

0

試試這個我的朋友

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
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.ncrypted.trademart.TmpAct"> 

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

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsingToolBar_hotel_home" 
     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/img_hotel_home" 
      android:layout_width="match_parent" 
      android:layout_height="300dp" 
      android:fitsSystemWindows="true" 
      android:scaleType="centerCrop" 
      android:src="@drawable/disha2" 
      app:layout_collapseMode="parallax" /> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbartmp" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_collapseMode="pin" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

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

    <android.support.design.widget.TabLayout 
     android:id="@+id/tablayoutymp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:tabGravity="fill" 
     app:tabMode="fixed" /> 

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


<android.support.v4.view.ViewPager 
    android:id="@+id/viewpagertmp" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

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

問我有任何疑問時

+0

我不明白你在這裏做什麼。你只是把TabLayout放在Collapsing工具欄的外面嗎?或者您剛剛刪除了文本,然後您將看不到該文本。我需要具備所有我提出的問題:S。 – neteot

+0

我只是提供給你示例模型如何添加標籤佈局與摺疊工具欄佈局,你可以根據你的要求修改它,我應該爲你提供一個它的屏幕截圖 –

相關問題