Android Scrollview不适用于Cardview
我一直在开发一个应用程序,但遇到了一个xml布局问题,当我在线性布局中使用卡片视图时,我通常使用的scrollview不起作用,我在google中查找并发现NestedScrollview仍然不起作用,AppForce关闭,有人能告诉我我到底做错了什么,并纠正了吗。这将非常有帮助 活动\u items\u details.xmlAndroid Scrollview不适用于Cardview,android,xml,android-layout,scrollview,nestedscrollview,Android,Xml,Android Layout,Scrollview,Nestedscrollview,我一直在开发一个应用程序,但遇到了一个xml布局问题,当我在线性布局中使用卡片视图时,我通常使用的scrollview不起作用,我在google中查找并发现NestedScrollview仍然不起作用,AppForce关闭,有人能告诉我我到底做错了什么,并纠正了吗。这将非常有帮助 活动\u items\u details.xml android:layout\u width=“匹配父项” android:layout\u height=“包装内容” android:layout\u margi
android:layout\u width=“匹配父项”
android:layout\u height=“包装内容”
android:layout\u margin=“8dp”>
您在
嵌套滚动视图
中有多个子视图,滚动视图
或嵌套滚动视图
只能承载一个子视图
若要修复布局,请将所有内容放入任何视图组,例如
LinearLayout
/RelativeLayout
,然后相应地排列视图如果不想尝试RecyclerView,请将LinearLayout放置在NestedScrollView之后,如下所示:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
您应该这样实现它:
<android.support.v4.widget.NestedScrollView
android:id="@+id/activity_Recipe_detail_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
// do what ever you need here
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
//你在这里需要什么
希望有此帮助为什么
NestedScrollView
在另一个NestedScrollView
中?抱歉,编辑了xml,在复制时发生了一些事情所以现在你的NestedScrollView
有多个子视图?Android初学者,我做错什么了吗?ScrollView只能有一个直接子视图。将外线布局放在NestedScrollView内。我想它应该会起作用
<android.support.v4.widget.NestedScrollView
android:id="@+id/activity_Recipe_detail_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
// do what ever you need here
</LinearLayout>
</android.support.v4.widget.NestedScrollView>