friends,
i have written following layout code and buttons to be displayed on screen equally but it not seems to work any one guide me what mistake am i doing?
![<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/color_panel_background"
>
<ImageButton
android:layout_height="wrap_content"
android:id="@+id/currentLocation"
android:layout_weight="1"
android:layout_width="fill_parent"
android:src="@drawable/current_location_icon"
/>
<ImageButton
android:layout_height="wrap_content"
android:id="@+id/searchCity"
android:layout_weight="1"
android:layout_width="fill_parent"
android:src="@drawable/search_icon"
/>
<ImageButton
android:layout_height="wrap_content"
android:id="@+id/home"
android:layout_weight="1"
android:layout_width="fill_parent"
android:src="@drawable/home_icon"
/>
</LinearLayout>
</RelativeLayout>][2]
The drawable for the middle button is obviously bigger than the other two. You set the height of the buttons with wrap_content, so the middle button gets bigger. Weight has nothing to do with this. Its only defining how much space the item takes when you use fill_parent.
Easiest way to fix this is either changing the layout_height to a fixed value (use dp as unit)
or change the size of your drawables making the images all the same size to begin with.
Thumbs up for the way you asked the question. Screenshot and relevant code. Wish everybody would do that 🙂