Android支持设计库中的CoordinatorLayout与WebView问题

3
我在我的应用程序中使用CoordinatorLayout和webview。但我遇到了像这张图片一样的问题:

(来源: duitang.com)

在4.4+上,我不知道我的布局有什么问题。

这是我的xml布局。

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipelayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <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:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="256dp"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleMarginEnd="64dp"
                app:expandedTitleMarginStart="48dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <ImageView
                    android:id="@+id/backdrop"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    android:scaleType="centerCrop"
                    app:layout_collapseMode="parallax" />

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

            </android.support.design.widget.CollapsingToolbarLayout>


        </android.support.design.widget.AppBarLayout>

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/nsv_scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="16dp">

                <WebView
                    android:id="@+id/webview"
                    style="@style/Widget.CardContent"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:minHeight="100dp">


                </WebView>


            </android.support.v7.widget.CardView>

        </android.support.v4.widget.NestedScrollView>

        <com.getbase.floatingactionbutton.FloatingActionButton xmlns:fab="http://schemas.android.com/apk/res-auto"
            android:id="@+id/floatingaction"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:clickable="true"
            app:layout_anchor="@id/appbar"
            app:layout_anchorGravity="bottom|right|end"
            fab:fab_colorNormal="?attr/colorAccent"
            fab:fab_colorPressed="?attr/colorAccentDark" />

    </android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>

期望的布局:
(来源:duitang.com)


你期望它看起来像什么? - Khalos
@Khalos 像这样 图片,webview 位于 appbarlayout 下方,而不是屏幕底部。 - adamin90
https://github.com/chrisbanes/cheesesquare/blob/master/app/src/main/res/layout/activity_detail.xml - Eugene H
1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接