我无法让GridLayout水平滚动.
我发现了一个类似的问题Gridlayout + ScrollView.我尝试了这种方法,但它没有用.
它会删除许多表(因为它应该显示从1到20的所有表).
这是xml文件
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:padding="16dp" > <android.support.v7.widget.GridLayout android:id="@+id/table_mapGrid" android:layout_width="250dp" android:layout_height="wrap_content" /> </LinearLayout> </ScrollView> <include layout="@layout/cell_list_loading" /> <TextView android:id="@+id/table_errorView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="20dp" android:text="@string/message_error_connection" android:visibility="invisible" /> </FrameLayout>
我希望显示动态内容,改变列和行的数量,可能在表之间有空格.
我已经完成了,但问题是当GridLayout的宽度变得大于其容器的宽度时,我想用水平滚动来解决它,但它似乎不起作用……
有什么建议吗?
解决方法
好吧,我找到了解决方案
似乎Android ScrollView作为VerticalScrollView工作,只有那个(名称不像HorizontalScrollView那么直观).
因此,要使某些内容可以垂直和水平滚动,您需要在HorizontalScrollView中嵌套(垂直)ScrollView,或者反过来,就像这样
<ScrollView android:layout_width="match_parent" android:layout_height="wrap_content"> <HorizontalScrollView android:layout_width="wrap_content" android:layout_height="match_parent"> <!-- Your content here --> </HorizontalScrollView> </ScrollView>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。