0

I'm trying to display as much as I can of listview items on a landscape mod, so I want to make the list view displays its items vertically, then when it exceeds the screen size it would display the next set of items beside the first set without showing the vertical scroll bar, but if it exceeds the screen width it would show a horizontal scroll bar. Here is how I want the listview to appears: enter image description here

The code I'm using displays the items vertically and then it adds scroll bar when ever listview width exceeds screen width. listview_fragment:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/pe"

     >

    <TextView
        android:id="@+id/textView124"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="#FF0817"
        android:text="ListView:"
        android:textSize="40sp"
        android:gravity="left"
        android:layout_marginLeft="22dp"
        android:textAppearance="?android:attr/textAppearanceLarge" />



     <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="fill_parent"

            android:layout_marginLeft="20dp"

            >

    <ListView
        android:id="@+id/list"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:dividerHeight="10dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="20dp"
        android:divider="@android:color/transparent" >

    </ListView>
  </LinearLayout>

</LinearLayout>

list_adapter.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="280dp"
    android:layout_height="90dp"
    android:orientation="horizontal"
    android:background="@drawable/border"
    android:layout_marginTop="10dp"
    android:padding="10dp"
     >

    <ImageView
        android:id="@+id/imgIcon"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_weight="0.1"
        android:gravity="center_vertical" 

         />
    <LinearLayout 
      android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:layout_weight="0.7"
    android:gravity="center_vertical"

        >
    <TextView
        android:id="@+id/txtTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:textSize="17sp"
        android:textColor="#D3D9FF"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="7dp"
           />
     <TextView
        android:id="@+id/txtTitle1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:layout_gravity="center_vertical"
        android:textSize="17sp"
        android:textColor="#D3D9FF"
        android:layout_marginLeft="7dp"
           />
      </LinearLayout>
</LinearLayout>

any help for this is truly appreciated... Thanks

Divya Jain
  • 393
  • 1
  • 6
  • 22
Ahmad Sanie
  • 3,678
  • 2
  • 21
  • 56

1 Answers1

1

Basically the functionality you describe is different from ListView. What you want is horizontally scrollable GridView. You will probably need to get this from a 3rd party library, some tips are mentioned below this question.

Community
  • 1
  • 1
Lamorak
  • 10,957
  • 9
  • 43
  • 57