Reputation: 5486
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
.
Upvotes: 2
Views: 7248
Reputation: 15525
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.
Upvotes: 9