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. 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.
You have to use RecyclerView for Horizontal scrollong like:
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
. Make LinearLayout
the parent layout of ListView
instead of RelativeLayout
and check it's work or not. I think it should be work.
<LinearLayout
..........>
<ListView
........
android:layout_weight="1"/>
</LinearLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.