android:fitsSystemWindows 无法在工具栏上运行
android:fitsSystemWindows not working on Toolbar
我正在使用来自 ksoichiro 的 android 库 Android-ObservableScrollView。我将他的示例 Flexible Space 与 viewpager 一起使用,并对其进行了修改。
但是有一些问题。你可以看到我的xml里面有2个android:fitsSystemWindows。一个在 LinearLayout 中,另一个在 Toolbar 中。在 LinearLayout 中工作良好。但在工具栏中不起作用。为什么会这样?
谢谢你。抱歉我的英语不好
这是我的 xml 代码:
<FrameLayout 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">
<com.github.ksoichiro.android.observablescrollview.TouchInterceptionFrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="@dimen/flexible_background"
android:scaleType="centerCrop"
android:src="@drawable/bridge" />
<View
android:id="@+id/overlay"
android:layout_width="match_parent"
android:layout_height="@dimen/flexible_background"
android:background="?attr/colorPrimary" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="@dimen/flexible_height">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
android:layout_margin="@dimen/abc_action_bar_default_padding_material"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:minHeight="?attr/actionBarSize"
android:textColor="@android:color/white"
android:textSize="20sp" />
</FrameLayout>
<com.bright.nongkrongyuk.ui.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@android:color/black"
app:sliding_textColor="@drawable/sliding_tab_profile" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light" />
</LinearLayout>
</com.github.ksoichiro.android.observablescrollview.TouchInterceptionFrameLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
android:minHeight="?attr/actionBarSize"
android:fitsSystemWindows="true" />
</FrameLayout>
android:fitsSystemWindows
属性设置填充。这意味着配件适用于子视图。您必须将此应用到您的 FrameLayout
或将 Toolbar
放入嵌套的 Layout
制作适合屏幕的视图的正确全屏布局真的很棘手。我将 Fragment 子类化,我可以在其中声明一个内容视图,该内容视图将根据状态获得填充 - and/or Navigationbar
我正在使用来自 ksoichiro 的 android 库 Android-ObservableScrollView。我将他的示例 Flexible Space 与 viewpager 一起使用,并对其进行了修改。 但是有一些问题。你可以看到我的xml里面有2个android:fitsSystemWindows。一个在 LinearLayout 中,另一个在 Toolbar 中。在 LinearLayout 中工作良好。但在工具栏中不起作用。为什么会这样? 谢谢你。抱歉我的英语不好
这是我的 xml 代码:
<FrameLayout 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">
<com.github.ksoichiro.android.observablescrollview.TouchInterceptionFrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="@dimen/flexible_background"
android:scaleType="centerCrop"
android:src="@drawable/bridge" />
<View
android:id="@+id/overlay"
android:layout_width="match_parent"
android:layout_height="@dimen/flexible_background"
android:background="?attr/colorPrimary" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="@dimen/flexible_height">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
android:layout_margin="@dimen/abc_action_bar_default_padding_material"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:minHeight="?attr/actionBarSize"
android:textColor="@android:color/white"
android:textSize="20sp" />
</FrameLayout>
<com.bright.nongkrongyuk.ui.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@android:color/black"
app:sliding_textColor="@drawable/sliding_tab_profile" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light" />
</LinearLayout>
</com.github.ksoichiro.android.observablescrollview.TouchInterceptionFrameLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
android:minHeight="?attr/actionBarSize"
android:fitsSystemWindows="true" />
</FrameLayout>
android:fitsSystemWindows
属性设置填充。这意味着配件适用于子视图。您必须将此应用到您的 FrameLayout
或将 Toolbar
放入嵌套的 Layout
制作适合屏幕的视图的正确全屏布局真的很棘手。我将 Fragment 子类化,我可以在其中声明一个内容视图,该内容视图将根据状态获得填充 - and/or Navigationbar