Java NestedScrollView中的Android约束布局渲染器问题
我正在尝试将ConstraintLayout添加到NestedScrollView。 检查我的约束布局时,一切看起来都很好 但是,将布局包括到嵌套的ScrollView中会折叠ContrainLayout(即使我在include和我的CL中使用了match parent width/heigt) 这实际上是以前版本的ContrainLayout(~pre-Beta)中的一个bug 我对Verion beta4采用这种方法 constraint_layout.xml:Java NestedScrollView中的Android约束布局渲染器问题,java,android,android-layout,Java,Android,Android Layout,我正在尝试将ConstraintLayout添加到NestedScrollView。 检查我的约束布局时,一切看起来都很好 但是,将布局包括到嵌套的ScrollView中会折叠ContrainLayout(即使我在include和我的CL中使用了match parent width/heigt) 这实际上是以前版本的ContrainLayout(~pre-Beta)中的一个bug 我对Verion beta4采用这种方法 constraint_layout.xml: <android.su
<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/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="de.project.andy.aliver.JobCreatorActivity">
<include layout="@layout/content_job_creator" />
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="145dp"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="143dp"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<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/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/jc_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/arrow_up_float"
android:layout_gravity="end|bottom"
app:fabSize="normal"
android:layout_margin="15dp" />
</android.support.design.widget.CoordinatorLayout>
<android.support.v4.widget.NestedScrollView 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="de.project.andy.aliver.JobCreatorActivity"
tools:showIn="@layout/activity_job_creator">
<include layout="@layout/constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
嵌套的\u scrollview\u layout.xml:
<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/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="de.project.andy.aliver.JobCreatorActivity">
<include layout="@layout/content_job_creator" />
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="145dp"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="143dp"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<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/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/jc_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/arrow_up_float"
android:layout_gravity="end|bottom"
app:fabSize="normal"
android:layout_margin="15dp" />
</android.support.design.widget.CoordinatorLayout>
<android.support.v4.widget.NestedScrollView 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="de.project.andy.aliver.JobCreatorActivity"
tools:showIn="@layout/activity_job_creator">
<include layout="@layout/constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
有解决办法吗?天哪……在没有答复的情况下重新搜索了一个小时。 创建SO帖子并在5分钟后找到答案 上述问题与ScrollView中的问题相同。解决办法是增加
android:fillViewport="true"
到可滚动的父级
因此嵌套的_scrollview_layout.xml将是:
<android.support.v4.widget.NestedScrollView
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:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="de.project.andy.aliver.JobCreatorActivity"
tools:showIn="@layout/activity_job_creator">
<include layout="@layout/constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
由于某些原因,Android Studio(从2.3.1开始)没有在NestedScrollView xml元素中自动建议此属性,因此我认为它不受支持。所以总是在这里帮忙:)