简体   繁体   English

Android中的水平列表视图?

[英]Horizontal list view in Android?

Looking for a horizontal list view GUI componnet in Android similar to UICollectionView in iOS. 在Android中寻找水平列表视图GUI组件,类似于iOS中的UICollectionView I trid ListView but was not able to set up to scroll it horizontally. 我尝试过ListView但是无法将其水平滚动。

I need only one line, so no grid like multi line 'table'. 我只需要一行,所以不需要像多行“表”那样的网格。 I know about TableLayout and GridLayout . 我知道TableLayoutGridLayout Which one is more proper for my purpose? 哪一个更适合我的目的?

Looking for not a 3rd party solution but a standard Android one without loading in and library. 寻找的不是第三方解决方案,而是寻找没有加载到库中的标准Android解决方案。

You should be using the RecyclerLayout, which allows you to specify your own LayoutManager (then you can specify a horizontal one, or a vertical one, or a grid one, or...) 您应该使用RecyclerLayout,它允许您指定自己的LayoutManager(然后可以指定水平的,垂直的或网格的或...)。

Here is a good SO with a simple example: How to build a Horizontal ListView with RecyclerView? 这是一个带有简单示例的优秀SO: 如何使用RecyclerView构建水平ListView?

You can use RecycleView and add horizontal layoutmanager 您可以使用RecycleView并添加水平layoutmanager

RecyclerView listView= (RecyclerView)findViewById(R.id.hlistview);

        LinearLayoutManager layoutManager=new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);
        listView.setLayoutManager(layoutManager);

and in xml 并在xml中

<android.support.v7.widget.RecyclerView
        android:id="@+id/hlistview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="30dp"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM