Scroll the entire list. View horizontally.

I have my own list view that contains 14 fields. Something like that:

field1 field2 field3 field4 field5 field6 field7 field8 field9 field10 field11 field12 field13 field14. Now the obvious problem is that there is no way that I can put all the fields on the screen, so I would like the whole list view to scroll horizontally, so I could only display 5-6 fields, and when the user scrolls horizontally, he will be able to see the rest. Do I have a list that scrolls both vertically and horizontally?

+4
source share
5 answers

just create a horizontal scroll list view, skeleton as follows

<HorizontalScrollView ...........> <LinearLayout ......> <LinearLayout ......> //List View Titles will be here </LinearLayout> <ListView ........ android:layout_weight="1" /> </LinearLayout> </HorizontalScrollView> 

Here, if you need to show the title without scrolling to view the list, add it to a separate layout, as described above, and do not forget to set the layout_weight attribute.

+8
source

List View already supports vertical scrolling, so we need to support horizontal scrolling. The code for the code worked fine for me. Be careful not to hold "height as 0dp" to view the list, even if "weight 1". Because HorizontalScrollView will take the height as zero and will not draw any item to represent the list.

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/table_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="58dp" android:layout_height="fill_parent" android:gravity="center" android:text="header" android:textColor="@android:color/black" /> <HorizontalScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@+id/mylist" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" > </ListView> </HorizontalScrollView> </LinearLayout> 
+1
source

Check this link . What do you want to do.

0
source

You should have a HorizontalScrollView, which should be a child of the VerticalScrollView, as indicated in this link .

0
source

The simplest and easiest way to implement a horizontal list.

Horizonatalscroll.xml

  <?xml version="1.0" encoding="utf-8"?> <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scroll" android:layout_width="fill_parent" android:layout_height="wrap_content" android:fadeScrollbars="false" android:background="@color/list_item_bg_color"> </HorizontalScrollView> 

horizontal_list.xml

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/horizontal_outer_layout" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margin="0dp" android:background="@drawable/rect_border_box" android:orientation="vertical" > <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </Linearlayout> 

java code:

  LinearLayout parent = (LinearLayout) getLayoutInflater().inflate( R.layout.observation_detail_parent_layout, null); Linearlayout child= null; //iterate views upto you adapater count. for(int i=0;i<14;i++){ child = (LinearLayout) getLayoutInflater().inflate( R.layout.horizontal_list, null); //set your views specified in horizontal_list.xml TextView text = (TextView) findViewById(R.id.text); text.setText("your text"); parent.addView(child); } 
0
source

All Articles