工具栏上的框架布局
FrameLayout on Toolbar
我的布局有问题,我使用以下代码通过 frameLayout 查看片段,但 FrameLayout 继续到工具栏 -
这里是 main.xml
<?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"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ab"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<include layout="@layout/toolbar"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_marginTop="33dp"
android:id="@+id/content_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.design.widget.CoordinatorLayout>
& 这是片段布局 -
web.xml
<RelativeLayout
xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:background="#FFFFFF"
>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/homefragmentFrameLayout1">
<WebView
android:id="@+id/web"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
<com.pnikosis.materialishprogress.ProgressWheel
android:id="@+id/pb"
android:layout_width="100dp"
android:layout_height="100dp"
wheel:matProg_barColor="?attr/colorAccent"
wheel:matProg_progressIndeterminate="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_marginTop="25dp"
android:src="@drawable/ref"
app:backgroundTint="@color/colorAccent"
app:elevation="6dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone"/>
</RelativeLayout>
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
将 app:layout_behavior="@string/appbar_scrolling_view_behavior"
添加到 Framelayout 以及 web.xml
中的 RelativeLayout
试试这个:
<FrameLayout
android:id="@+id/content_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
我的布局有问题,我使用以下代码通过 frameLayout 查看片段,但 FrameLayout 继续到工具栏 -
这里是 main.xml
<?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"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ab"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<include layout="@layout/toolbar"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_marginTop="33dp"
android:id="@+id/content_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.design.widget.CoordinatorLayout>
& 这是片段布局 - web.xml
<RelativeLayout
xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:background="#FFFFFF"
>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/homefragmentFrameLayout1">
<WebView
android:id="@+id/web"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
<com.pnikosis.materialishprogress.ProgressWheel
android:id="@+id/pb"
android:layout_width="100dp"
android:layout_height="100dp"
wheel:matProg_barColor="?attr/colorAccent"
wheel:matProg_progressIndeterminate="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_marginTop="25dp"
android:src="@drawable/ref"
app:backgroundTint="@color/colorAccent"
app:elevation="6dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone"/>
</RelativeLayout>
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
将 app:layout_behavior="@string/appbar_scrolling_view_behavior"
添加到 Framelayout 以及 web.xml
试试这个:
<FrameLayout
android:id="@+id/content_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />