As you can see from the xml imagebutton,linearlayout and Horizontalscrollview have wrap_content for their height.But it seems that the Horizontalscrollview sometimes has more height than linearlayout.Its height is supposed to be equal to that of its child.
How can I make the height of Horizontalscrollview equal to its child using wrap_content?
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bottom_bar_light"
android:fillViewport="true" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/new_file"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:onClick="onClick"
android:src="@drawable/new_item" />
<ImageButton
android:id="@+id/multi_select"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:onClick="onClick"
android:src="@drawable/discard_small" />
<ImageButton
android:id="@+id/refresh"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:onClick="onClick"
android:src="@drawable/refresh_small" />
<ImageButton
android:id="@+id/home_grid"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:onClick="onClick"
android:src="@drawable/grid_small" />
<ImageButton
android:id="@+id/info_button"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:onClick="onClick"
android:src="@drawable/info_small" />
<ImageButton
android:id="@+id/exit"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:onClick="onClick"
android:src="@drawable/exit" />
</LinearLayout>
</HorizontalScrollView>
Make sure the background drawable that you use for the HorizontalScrollView
, @drawable/bottom_bar_light
, is not too big to force the widget be taller than it should.