如何创建水平列表视图? Android
How to create a horizontal list view? Android
我很难创建水平列表视图,我希望所有项目都可以水平滚动。我试过了,但列表仍然以其常规格式显示。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TO SEE IF HORIZ"/>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ListView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/listViewGlobal"
android:ori>
</ListView>
</HorizontalScrollView>
</RelativeLayout>
您的问题是您将 ListView
放在 HorizontalScrollView
中,您遇到的垂直滚动是由 ListView
.
引起的
将你的 ListView
换成 LinearLayout
在你体内 HorizontalScrollView
以使其发挥作用。
另外,看看Horizontal ListView in Android?
如果你想创建水平列表,你可以使用:
1)RecyclerView
与 GridLayoutManager.HORIZONTAL
或 LinearLayoutManager.HORIZONTAL
我很难创建水平列表视图,我希望所有项目都可以水平滚动。我试过了,但列表仍然以其常规格式显示。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TO SEE IF HORIZ"/>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ListView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/listViewGlobal"
android:ori>
</ListView>
</HorizontalScrollView>
</RelativeLayout>
您的问题是您将 ListView
放在 HorizontalScrollView
中,您遇到的垂直滚动是由 ListView
.
将你的 ListView
换成 LinearLayout
在你体内 HorizontalScrollView
以使其发挥作用。
另外,看看Horizontal ListView in Android?
如果你想创建水平列表,你可以使用:
1)RecyclerView
与 GridLayoutManager.HORIZONTAL
或 LinearLayoutManager.HORIZONTAL