私は主なアクティビティに3つのタブを持つアプリケーションで作業しています。 2番目のタブのフラグメントには、ヘッダー付きのNestedScrollViewがあり、これをシステムウィンドウに合わせる必要があります。タブの残りの部分は、ツールバーを使って正常に表示されます。現在のタブが2番目の場合はsetFitsSystemWindows(true)
に設定し、それ以外の場合はfalse
に設定します。それは最初の実行(最初のタブで)に続いて2番目のタブに移動しますが、1番目のタブに戻るとバグが発生します。 1番目のタブに戻るとツールバーがシステムウィンドウに合ったときにfalse
に設定されているようです。以下This is the screenshot of the toolbar when going back to 1st tabfitSystemWindowsはタブの1つのフラグメントにのみ適用されます
私MainActivityのXMLコードです:タブを切り替えたとき、私はこのようなsetFitsSystemWindowsにブール値を設定するコードで
<?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:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetStart="0dp"
app:navigationIcon="@drawable/ic_search"
app:title="Our Menu" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<au.com.appetiser.youfoodz.widgets.bottom_navigation.BottomNavigationLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical"
app:layout_behavior="au.com.appetiser.youfoodz.view.GenericBottomBehavior">
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
android:background="@android:color/white"
app:elevation="0dp"/>
</au.com.appetiser.youfoodz.widgets.bottom_navigation.BottomNavigationLayout>
</android.support.design.widget.CoordinatorLayout>
:
@Override
public void onTabTransaction(Fragment currentFragment, int i) {
rootLayout.setFitsSystemWindows(currentFragment instanceof SecondFragment);
}
あなたがこれまでにやっていること、あなたのコードを投稿しますか?だから我々は助けることができる –
@rajanksありがとう男。上記の質問を更新しました:) – kebbbnnn