2016-05-30 14 views
0

コーディネータレイアウトに問題があります。私は、親CoordinatorLayout(私はツールバーを非表示にしたい)とappBarLayout内のアクティビティツールバーを持っていて、appBarLayoutとviewPagerの中にtablayoutでフラグメント化しています。ここでは、アクティビティのXMLアクティビティ外のコーディネータレイアウト内のtablayoutを非表示にする

<?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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/gradient" 
    android:fitsSystemWindows="true"> 

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

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways|snap" 
      app:popupTheme="@style/AppTheme.PopupOverlay"/> 

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

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

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

あり、それは、私はツールバーがどこかにある。このような状況を持って、今のフラグメントのXML

<?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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/gradient" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/toolbar_container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      style="@style/MyCustomTabLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:tabGravity="fill"/> 

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

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

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

です。 Have no toolbar

私は、リニアレイアウトに活動内部コーディネーターのレイアウトを変更した場合、私は目に見えるツールバーが、あなたがいない隠しオプションで想像できるよう得ます。あなたが確認することができますので、私はそれがどのように動作するかを少し理解している、https://github.com/Iamtodor/toolbars :)

- 隠しといくつかの例など、視差およびその他のツールバーを示す:

実は、私がコーディネーターと遊ぶいるが、多くのレイアウトhttps://github.com/codepath/android_guides/wiki/Using-the-App-ToolBar#using-toolbar-as-actionbar - - - https://github.com/codepath/android_guides/wiki/Handling-Scrolls-with-CoordinatorLayout https://github.com/chrisbanes/cheesesquare

をしかしtablayoutは、ツールバーと同じappbarlayoutの内側に存在する場合、すべての例があります:また、私はこのソースをwantchました。

どうすれば修正できますか?ここで

+0

はまだ答え – iamtodor

+0

UPを探して、それは可能ですしてください? – iamtodor

+0

私も同様の問題があります。私は何を見つけるのか教えてくれます。 – dazza5000

答えて

0

は私のために働いていたものです:

フラグメントXML:

<android.support.design.widget.AppBarLayout 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/app_bar_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:elevation="0dp"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_scrollFlags="scroll|enterAlways|snap" > 

     <include layout="@layout/include_time_line" 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" /> 
    </android.support.v7.widget.Toolbar> 

    <android.support.design.widget.TabLayout 
     style="@style/TabLayout" 
     android:id="@+id/tabLayout" 
     android:layout_width="match_parent" 
     android:layout_height="54dp" 
     android:layout_gravity="bottom" 
     android:background="@color/egg" 
     android:elevation="0dp" 
     app:tabGravity="fill" 
     app:tabMode="scrollable" 
     app:tabIndicatorColor="#fcd131" 
     app:tabPadding="0dp" 
     app:tabIndicatorHeight="4dp"/> 
</android.support.design.widget.AppBarLayout> 

<com.woot.woot.productbrowse.ui.ConfigurablePagingViewPager 
    android:id="@+id/viewPager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    /> 
<FrameLayout 
    android:id="@+id/selectByWeightKeyboard" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/weight_keyboard_container_height" 
    android:background="@color/keyboard" 
    android:clipToPadding="false" 
    android:elevation="16dp" 
    android:clickable="true" 
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> 

    <include layout="@layout/add_product_by_weight_keyboard" /> 
</FrameLayout> 

活動XML:

<FrameLayout 
     android:id="@+id/contentFrame" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <FrameLayout 
     android:id="@+id/layout_done_button" 
     android:visibility="gone" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:elevation="8dp" 
     tools:visibility="visible" 
     android:background="@color/ice"> 

     <Button 
      android:id="@+id/button_done" 
      style="?android:attr/borderlessButtonStyle" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/button_height" 
      android:layout_marginRight="@dimen/button_done_horizontal_margin" 
      android:layout_marginLeft="@dimen/button_done_horizontal_margin" 
      android:layout_marginTop="@dimen/activity_horizontal_margin" 
      android:layout_marginBottom="@dimen/activity_horizontal_margin" 
      android:background="@drawable/rounded_green_button" 
      android:text="@string/done" 
      android:textSize="@dimen/button_text_size" 
      android:textAllCaps="true" 
      android:textColor="@color/egg" /> 
    </FrameLayout> 

<android.support.design.widget.NavigationView 
    android:id="@+id/navigation" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:contentDescription="@string/drawer_content_description" 
    app:menu="@menu/menu_navigation_product_browse" /> 

関連する問題