0

FragmentsにはViewPagerFragmentsがあり、フルスクリーンイメージといくつかの下部調整コントロールが含まれています。ViewPagerとfitsSystemWindowを使用してステータスバーの背後にあるコントロール

私はコントロールがfitsSystemWindowで半透明のナビゲーションバーの後ろに消えることはありませんが、私はそれを動作させるように見えることはできませんを確認する...

私は同じXMLを使用する場合それはViewPagerせずに動作しませんしたがって、ViewPagerfitsSystemWindowを使用する機能を「中断」しているようです。

コードIは、活性のために持っている:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 
</FrameLayout> 

は、これは私がフラグメントのために持っているものです。

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:background="#000" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/initial_background_image" 
     android:scaleType="centerCrop"/> 

    <RelativeLayout 
     android:id="@+id/buttons_container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="@dimen/button_icon_offset" 
     android:layout_marginBottom="@dimen/button_icon_offset" 
     android:layout_marginRight="@dimen/button_icon_offset" 
     android:fitsSystemWindows="true" 
     android:layout_gravity="bottom"> 

     <Button 
      android:id="@+id/info_button" 
      style="@style/button_icon" 
      android:layout_gravity="left|bottom" 
      android:background="@drawable/button_info" 
      android:textAlignment="center"/> 

     <Button 
      android:id="@+id/share_button" 
      style="@style/button_icon" 
      android:layout_alignTop="@id/info_button" 
      android:layout_marginRight="@dimen/button_icon_divider" 
      android:layout_toLeftOf="@+id/like_button" 
      android:background="@drawable/button_share"/> 

     <Button 
      android:id="@+id/like_button" 
      style="@style/button_icon" 
      android:layout_alignParentRight="true" 
      android:background="@drawable/button_like"/> 
    </RelativeLayout> 
</FrameLayout> 

は、これは私がで終わるものです...しかし、私は、ボタンが欲しいです表示される上記のの上に表示されます。

This is what I dont want

答えて

0

まず、WindowInset Sに関するthisの答えを参照してください。それでは、ルートレイアウト - FrameLayoutWindowInsetViewPagerに発送しないことを理解します。 ViewPagerWindowInset Sを派遣し、あなたのViewPagerフィットウインドインセットを作る、すなわち、両方のViewPagerandroid:fitsSystemWindows="true"を適用し、それは親のために

使用ViewCompat.setOnApplyWindowInsetsListener() API。それでも動作しない場合

+0

答えていただきありがとうございます。私が得ることができないことは、FrameLayout内にボタンを複数回ラップしても、アクティビティで同様のレイアウトを使用すると機能するということです。それで 'fitsSystemWindows'はネストされた子ビューの中でも動作します。 – Thijs

0

だけの変更/あなたstyle.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    ...  
    <item name="android:windowDrawsSystemBarBackgrounds">false</item> 
    ... 
</style> 

でこれを削除しますか?あなたがNestedScrollViewを使用しているし、「アンドロイド:clipToPadding」追加

<android.support.v4.widget.NestedScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/light_green" 
      android:clipToPadding="false" <--add this 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
0

をあなたは、ナビゲーションバーの上に配置するボタンにマージン底を追加することができます。

android:layout_marginBottom="?attr/actionBarSize" 
関連する問題