0

我使用Appbarlayout隨後cordinatorlayout用RecyclerView只是摺疊/展開一個簡單的TextView。但仍然不知道我在那裏做錯了什麼。 TextView(textViewMainTop)仍然沒有合攏/展開。無法找出問題。請看看我的 xml代碼。無法摺疊/展開視圖中Appbarlayout

<?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"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="7" 
     android:orientation="vertical" > 

     <!-- <LinearLayout 
      android:id="@+id/container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="3.5" > --> 

      <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="3.5"> 

      <com.openskylabs.skymo.components.TypefacedTextView 
       android:id="@+id/textViewMainTop" 
       style="@style/custom_roboto_midium" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@drawable/bubbled_textview" 
       android:gravity="center" 
       app:layout_scrollFlags="scroll|enterAlways" 
       android:text="Good evening, Eric" 
       android:textSize="17dp" /> 

      </android.support.design.widget.AppBarLayout> 
     <!-- </LinearLayout> --> 

     <LinearLayout 
      android:id="@+id/llTabLayout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="6.5" 
      android:orientation="horizontal"> 

      <LinearLayout 
       android:id="@+id/llFirstFavTab" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:gravity="center" 
       android:orientation="horizontal" > 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/ic_fev_small" /> 

       <com.openskylabs.skymo.components.TypefacedTextView 
        style="@style/custom_roboto_midium" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="5sp" 
        android:text="Set Fav" /> 
      </LinearLayout> 

      <View 
       android:id="@+id/viewVertical" 
       android:layout_width="0.5sp" 
       android:layout_height="match_parent" 
       android:background="#60000000" /> 

      <LinearLayout 
       android:id="@+id/llSecondInviteTab" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:gravity="center" 
       android:orientation="horizontal" 
       android:visibility="visible" > 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/ic_cont_small" /> 

       <com.openskylabs.skymo.components.TypefacedTextView 
        style="@style/custom_roboto_midium" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="5sp" 
        android:text="Invite" /> 
      </LinearLayout> 
     </LinearLayout> 

     <View 
      android:id="@+id/viewBelowRay" 
      android:layout_width="match_parent" 
      android:layout_height="1sp" 
      android:background="#60000000" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="3" 
     android:background="#eaeaea" 
     android:gravity="center" 
     android:orientation="vertical" > 


     <android.support.v7.widget.RecyclerView 
      android:id="@+id/rvOrderList" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:visibility="gone" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 
    </LinearLayout> 

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

enter image description here

在這裏,我要崩潰了第一部分。在第二部分中,我使用了RecyclerView。

+0

什麼是確切的問題?張貼截圖。 –

+0

您面臨什麼樣的性能問題請詳細說明問題。 – Umair

+0

@jaydroider我只想摺疊/展開TextView的(textViewMainTop)..所以我把它放在Appbarlayout ..但遺憾的是其並沒有崩潰。 – Ranjit

回答

1

你應該使用CollapsingToolbarLayoutAppBarLayout崩潰你想要的部件。你Text View走了進去CollapsingToolbarLayout

篩選。

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


     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapse_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:contentScrim="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 
+0

嘗試刪除的LinearLayout。應該是CoordinatorLayout - > AppBarLayout - > CollapsingToolbarLayout - > TypefacedTextView – ayvazj

+0

酷jay..lets有一個嘗試 – Ranjit

+0

@jaydroider沒有它仍然沒有工作.. – Ranjit