【问题标题】:GridView with 2 rows and multiple Columns Horizontal Scroll Dynamically in Android2行多列的GridView在Android中动态水平滚动
【发布时间】:2014-11-02 12:52:22
【问题描述】:
我遇到了GridView 的问题。我需要一个水平滚动,带有一个GridView,它有 2 行和多列,具体取决于动态数据。有人知道如何实现吗?我尝试在ScrollView 中使用TableLayout,但这是单独滚动每个表格行。当用户滑动屏幕时,我需要滚动两行。
如果可以的话,谁能告诉我。如果是这样,任何参考或样本。请大家帮忙,谢谢大家。
【问题讨论】:
标签:
android
gridview
horizontal-scrolling
【解决方案2】:
您可以使用HorizontalScrollView 代替ScrollView。就像这样:
<HorizontalScrollView>
<LinearLayout orientation="vertical">
<LinearLayout id="first_row" orientation="horizontal">
// Add custom view programmatically inside this first row
</LinearLayout>
<LinearLayout id="second_row" orientation="horizontal">
// Add custom view programmatically inside this second row
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>