2016-04-27 12 views
2

私に問題があり、修正できません。 設定する画像がない場合、折りたたみツールバーを展開できないようにしたいと思います。 私の断片では、設定するイメージがないときにイメージビューの表示をGONEに設定しましたが、そうすることで私のツールバーは消えてしまいました(タイトルがなくなり、メニューは表示されなくなりました)。 誰かが折り畳みツールバーの展開を無効にする方法を知っていますか?私の最初のフラグメントでcollaspsingtoolbarを無効にする

私のXML

<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/coordinator_layout" 
     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:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     android:fitsSystemWindows="true"> 

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

      <ImageView 
       android:id="@+id/image" 
       android:layout_width="match_parent" 
       android:layout_height="250dp" 
       android:scaleType="centerCrop" 
       android:src="@drawable/landscape" 
       android:fitsSystemWindows="true" 
       app:layout_collapseMode="parallax"/> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/toolbar_height" 
       android:layout_below="@+id/image" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
       app:layout_collapseMode="pin" /> 


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

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom"/> 

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

     <android.support.v4.widget.NestedScrollView 
      android:id="@+id/scroll" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:clipToPadding="false" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
    <FrameLayout 
     android:id="@+id/main_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/tabLayout" /> 
     </android.support.v4.widget.NestedScrollView> 
    </android.support.design.widget.CoordinatorLayout> 

<android.support.design.widget.NavigationView 
    android:id="@+id/navigation_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/menu_recycler_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="20dp" 
     android:layout_marginLeft="10dp"> 
    </android.support.v7.widget.RecyclerView> 

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

VISIBLEにImageViewの可視性を設定し、私の第2の断片に私はGONEへの可視性を設定されています。

誰かがそう考えていれば素晴らしいだろう!フラグメントで

+0

あなたは見えませんでしたか? (これとは対照的に)視界を隠すが位置は維持される。 – MikeT

+0

まあ、不可視の問題は、私のcollapsingtoolbarが拡張可能で、私はそうしたくないということです。 – Tibo

答えて

0

、あなたのケースで

mAppBarLayout.setExpanded(false, false);

mRecyclerView.setNestedScrollingEnabled(false);// NestedScrollView

ツールバーは決して拡張されません。

関連する問題