My image button is 40px in height, but my gallery is a lot bigger in height. Right now, my imagebuttons take up the entire space they are given, and is the same height as my gallery. Is there anway to keep the buttons their original size while keeping this horizontal layout?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="20dp" >
<ImageButton
android:id="@+id/left_arrow"
android:layout_weight="3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shared_arrow_left_button_selector"
android:scaleType="fitCenter" />
<Gallery
android:id="@+id/gallery"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:spacing="15dp" />
<ImageButton
android:id="@+id/right_arrow"
android:layout_weight="3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shared_arrow_right_button_selector"
android:scaleType="fitCenter" />
</LinearLayout>
You are applying
to both the ImageButtons so they are filling the height, if you just want ImageButtons to wrap their original size just change them to
wrap_contentand remove thelayout_weightproperty. Also when you are applyinglayout_weight="1"to gallery just changeandroid:layout_width="0dp"as the width will be managed by thelayout_weightproperty itself. Your final layout should be like,