2016-05-01 12 views
1

私は現在、画像を崩壊させるためにコーディネータレイアウトを使用しようとしている - 透明ステータスバーとテーマに - しかし、3つの問題は、私を悩ませていますコーディネーターのレイアウトと透明ステータスバー

  1. 活動がありますステータスバーの後ろにイメージが表示されていません(コーディネータレイアウトを削除しても動作します)。
  2. スクロールアップすると、ステータスバーを単色に変更したいのですが、画像の一部が表示されたままになります。
  3. AppBarLayoutとCollapsingToolbarLayoutを追加した後、ステータスバーの高さが同じで画像の下端が切れます。

image below status bar - even though it is set to be transparent in the theme 画像は、ステータスバーの下に残っている -

Status bar after collapsing - it should have a solid color ステータスバー崩壊後のテーマに透明になるように設定されていても - それはソリッドカラー

を持つべきですコード:

<?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="@color/colorPrimary" 
    android:orientation="vertical"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     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:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" 
      app:statusBarScrim="@color/colorPrimary" 
      app:contentScrim="@color/colorPrimaryDark"> 

      <RelativeLayout 
       android:id="@+id/cover_wrapper" 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/rsc_character_details_cover_height"> 

       <ImageView 
        android:id="@+id/cover" 
        android:layout_width="match_parent"     android:layout_height="@dimen/rsc_character_details_cover_height"/> 
      </RelativeLayout> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/cover_wrapper" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

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

は、これは私がステータスバーの透明度を設定しています方法です:

<item name="android:windowTranslucentStatus">true</item> 

すべてのヘルプは非常に理解されるであろう。 ありがとうございます。

+1

これは、 'CollapsingToolbarLayout'が' Toolbar'のラッパーであるためです。 – tachyonflux

答えて

2

イメージがステータスバーの後ろに表示されず、切断される問題については、ステータスバー領域に表示されるものはandroid:fitsSystemWindows="true"である必要があります。すなわち、 cover_wrappercover

+0

それだけです!ありがとうございます –

+0

反対ではありませんか? docs:android:fitsSystemWindows ステータスバーなどのシステムウィンドウに基づいてビューレイアウトを調整するブール内部属性。 trueの場合、このビューのパディングを調整して、システムウィンドウのスペースを確保します。 – GPack

+0

@GPackいくつかのデザインライブラリコンポーネントは、フラグの動作を変更します。https://medium.com/google-developers/why-would-i-want-to-fitssystemwindows-4e26d9ce1eec – tachyonflux

関連する問題