Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

horizontal Linear Layout inside horizontal scroll view

layout.xml

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" >

 <HorizontalScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:id="@+id/itemlist"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/itemlistbg"
        android:gravity="center_vertical"
        android:orientation="horizontal"/>

 </HorizontalScrollView>

</LinearLayout>

I am adding children to linear layout id itemlist dynamically. if items are too many then result is ok. But if there is 2 items in list then linear layout itemlist leaves a space at the end. this only happens on big screen devices.

eclipse preview of xml

like image 589
Mr Roshan Pawar Avatar asked Jun 29 '26 22:06

Mr Roshan Pawar


1 Answers

Try to change your scrollview like this.

<HorizontalScrollView
    android:layout_width="fill_parent"
    android:background="@drawable/itemlistbg"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:id="@+id/itemlist"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"        
        android:gravity="center_vertical"
        android:orientation="horizontal"/>

 </HorizontalScrollView>

I hope this will help you.

like image 120
Gunaseelan Avatar answered Jul 02 '26 12:07

Gunaseelan