在 CoordinatorLayout 内的 Cardview 内带有 EditText 的 NestedScrollview 不填充视口
NestedScrollview with an EditText inside Cardview inside CoordinatorLayout doesn't fill viewport
我的 activity 中有一个类似于以下的布局:
<android.support.v7.widget.CardView
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="10dip"
android:paddingRight="10dip">
<EditText
android:id="@+id/noteBodyEdit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textCapSentences|textMultiLine"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v7.widget.CardView>
此视图作为内容视图包含在 CoordinatorLayout 中,并添加了带有工具栏的标准 AppbarLayout。
使用此代码,我希望 Scrollview 和 EditText 填充所有内容视图。但是,在这种形式中,它们以 wrap_content 行为结束。
如果我更改代码并将 layout_behavior 从 CardView 移动到 Scrollview,填充端口视图问题会得到修复,但内容会被工具栏部分覆盖。
关于如何使用任一方法解决此问题的任何想法:
- 在 CardView 上使用行为并拉伸 ScrollView 以填充视口
- 或者,在 ScrollView 上使用行为并使其显示在工具栏下方。
在我更新到支持库 23.0.0 后,问题似乎消失了。
我的 activity 中有一个类似于以下的布局:
<android.support.v7.widget.CardView
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="10dip"
android:paddingRight="10dip">
<EditText
android:id="@+id/noteBodyEdit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textCapSentences|textMultiLine"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v7.widget.CardView>
此视图作为内容视图包含在 CoordinatorLayout 中,并添加了带有工具栏的标准 AppbarLayout。
使用此代码,我希望 Scrollview 和 EditText 填充所有内容视图。但是,在这种形式中,它们以 wrap_content 行为结束。
如果我更改代码并将 layout_behavior 从 CardView 移动到 Scrollview,填充端口视图问题会得到修复,但内容会被工具栏部分覆盖。
关于如何使用任一方法解决此问题的任何想法:
- 在 CardView 上使用行为并拉伸 ScrollView 以填充视口
- 或者,在 ScrollView 上使用行为并使其显示在工具栏下方。
在我更新到支持库 23.0.0 后,问题似乎消失了。