[英]how to put listview inside a horizontalscrollview so that list can scroll hoizontally?
i am creating an application where requirement is like i have list which scroll vertically and inside that list each item is having one list which must scroll horizontally. 我正在创建一个要求像我有一个垂直滚动列表的应用程序,并且在该列表内部,每个项目都有一个必须水平滚动的列表。 So i have to set that list inside horizontal scroll view. 所以我必须在水平滚动视图中设置该列表。 i have created a custom adpater for that data is showing on the list everything is working fine but only one problem the list is scrolling vertically because i was unable to set that list horizontal. 我已经为该数据创建了一个自定义adpater,该数据在列表中显示一切正常,但是只有一个问题是列表垂直滚动,因为我无法将列表水平设置。 Please help i have searched lots of answers but it is not working. 请帮助我搜索了很多答案,但是没有用。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<android.support.v7.widget.CardView
android:id="@+id/card_view_applicant"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:background="#fff"
app:cardCornerRadius="8dp"
app:cardElevation="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_table_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="T1"
android:textAlignment="center"
android:textColor=" #00008B"
android:textSize="25sp"
android:textStyle="bold" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#000000" />
</LinearLayout>
<HorizontalScrollView
android:id="@+id/hsv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:measureAllChildren="false"
android:scrollbars="none">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_marginLeft="50dp"
android:layout_height="match_parent">
<ListView
android:id="@+id/lv_timing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</HorizontalScrollView>
</android.support.v7.widget.CardView>
</RelativeLayout>
</LinearLayout>
i have tried to do something like this this is but it is not working,and i don't want to use any recyclerview my requirement is just simple i just want to show some that that's why. 我试图做这样的事情,但这是行不通的,并且我不想使用任何recyclerview,我的要求很简单,我只想显示一些这就是为什么。
You have to use RecyclerView for Horizontal scrollong like: 您必须使用RecyclerView进行水平滚动,例如:
LinearLayoutManager layoutManager= new
LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(layoutManager);
Use android:layout_weight="1"
inside ListView
. 在ListView
使用android:layout_weight="1"
。 Make LinearLayout
the parent layout of ListView
instead of RelativeLayout
and check it's work or not. 将LinearLayout
设为ListView
的父级布局,而不是RelativeLayout
然后检查其是否正常工作。 I think it should be work. 我认为应该工作。
<LinearLayout
..........>
<ListView
........
android:layout_weight="1"/>
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.