Android : ListView desplays item vertically and when the items exceed the screen size it displays them horizontally?

on Wednesday, April 15, 2015


i'm trying to display as much as i can of listview items on a landscape mood 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 is truly appreciated... Thanks


0 comments:

Post a Comment