[英]Android XML Scroll View not scrolling
I have a linear layout that holds a scroll view that holds another Linear Layout which then holds the content.我有一个线性布局,其中包含一个滚动视图,该滚动视图包含另一个线性布局,然后再包含内容。 But for some reason, I can't scroll with it?
但由于某种原因,我不能滚动它? I've tried a NestedScrollView too but that also did not work.
我也尝试过 NestedScrollView,但这也没有用。 I read that you are supposed to use wrap content and I am but still not scrolling.
我读到你应该使用包装内容,但我仍然没有滚动。 My Code:
我的代码:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/viewsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/belgrano"
android:paddingLeft="@dimen/activity_detail_horizontal_margin"
android:paddingTop="40dp"
android:paddingBottom="10dp"
android:text="@string/empty_textview"
android:textDirection="locale"
android:textSize="@dimen/textsize_m" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:src="@drawable/divider" />
<TextView
android:id="@+id/dateText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/belgrano"
android:paddingLeft="@dimen/activity_detail_horizontal_margin"
android:paddingTop="20dp"
android:paddingRight="@dimen/activity_detail_horizontal_margin"
android:paddingBottom="10dp"
android:text="@string/empty_textview"
android:textDirection="locale"
android:textSize="@dimen/textsize_m" />
<TextView
android:id="@+id/descriptionText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/belgrano"
android:paddingLeft="@dimen/activity_detail_horizontal_margin"
android:paddingTop="20dp"
android:paddingRight="@dimen/activity_detail_horizontal_margin"
android:paddingBottom="10dp"
android:text="@string/empty_textview"
android:textDirection="locale"
android:textSize="@dimen/textsize_m" />
<TextView
android:id="@+id/sponsor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/belgrano"
android:paddingLeft="@dimen/activity_detail_horizontal_margin"
android:paddingTop="20dp"
android:paddingRight="@dimen/activity_detail_horizontal_margin"
android:paddingBottom="10dp"
android:text="@string/empty_textview"
android:textDirection="locale"
android:textSize="@dimen/textsize_m" />
</LinearLayout>
</ScrollView>
All help is appreciated thank you!感谢所有帮助谢谢!
It seems like the issue is due to Scrollview's height itself.问题似乎是由于 Scrollview 本身的高度。
change this改变这个
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
to this对此
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
if that doesn't work, check if the parent of scroll view is giving it enough space.如果这不起作用,请检查滚动视图的父级是否给它足够的空间。 the hierarchy should be like this if you want a scrollable form
如果你想要一个可滚动的表单,层次结构应该是这样的
**Main layout** with match_parent height and width-> **Scroll view** with match_parent height and width -> **Linear/Constraint layout** with wrap_content height and match parent width -> Views to be scrolled
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.