2016-06-11 4 views
1

CollapsingToolbarLayoutの実装に問題があります。CollapsingToolBarLayoutにはデュアルツールバーがあります

はい、レイアウトにビューを配置する必要がありますが、下の図に示すように、元のツールバー(またはそれに関するActionBar)の下に折り畳まれています。私はこれをどのように修正するのか分かりません。 The <code>CollapsingToolbarLayout</code> collapses under the <code>ActionBar</code>

ありがとうございました。私はAndroid Studio 2.1.1を使用しています。私が間違っていたところ、私が見つけた

<?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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".ArticleActivity"> 

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

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

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:id="@+id/featuredImage" 
       android:src="@mipmap/ic_launcher" 
       android:scaleType="centerCrop" 
       android:fitsSystemWindows="true" 
       app:layout_collapseMode="parallax" 
       android:contentDescription="@string/article_image"/> 
      <android.support.v7.widget.Toolbar 
       android:id="@+id/tool_bar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:layout_collapseMode="pin" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 

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

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

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:clipToPadding="false" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
     <WebView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/article_container" /> 
    </FrameLayout> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/share" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@mipmap/ic_share_variant" /> 

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

あなたのアクティビティのテーマは、「NoActionBar」ベースのテーマのいずれかを拡張しますか? – EricDS

+0

@EricDSはいそうです。 –

答えて

0

は、ここに私のレイアウトファイルです。私はマニフェストにテーマ・ステートメントを除外しました。私がしなければならなかったのは、マニフェストの私の活動にandroid:theme="AppTheme.NoActionBar"という行を追加することでした。 (トップに固執しません。)ビューのうち

  1. 新しいツールバーをスクロール

  2. 私を導くべきである戻るボタンを:

    はしかし、これは、2つの新しい問題を育てました私の以前の活動には行っていません。しかし、私が研究の解決策を得られないなら、これを別の質問として尋ねます。

+0

私は 'NestedScrollView'に変更した' FrameLayout'から 'app:layout_scrollFlags'行を削除して最初の問題を解決しました。しかし、問題#2は依然として続きます。 –

関連する問題