I have a relative layout within another layout that represents a menu bar on the bottom of the screen. no i wand the four menu icons be symmetrically distributet on the menu bar.
here is my code so far. problem is i dont want to set absolute “dip” values. is there a way to somehow get the screenwith and devide it by four ?
<RelativeLayout
android:layout_height="80dip"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:background="@android:color/black"
android:layout_alignParentBottom="true" >
<ImageButton
android:layout_alignParentBottom="true"
android:layout_width="70dip"
android:layout_height="70dip"
android:id="@+id/homeButton"
android:layout_alignParentLeft="true"
android:src="@drawable/homeicon"/>
<ImageButton
android:id="@+id/searchButton"
android:layout_width="70dip"
android:layout_toRightOf="@+id/homeButton"
android:layout_alignParentBottom="true"
android:layout_height="70dip"
android:src="@drawable/searchicon"/>
<ImageButton
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/searchButton"
android:layout_width="70dip"
android:layout_height="70dip"
android:id="@+id/bookmarksButton"
android:src="@drawable/bookmarksicon" />
<ImageButton
android:id="@+id/settingsButton"
android:layout_width="70dip"
android:layout_toRightOf="@+id/bookmarksButton"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_height="70dip"
android:src="@drawable/settingsicon" />
I think I see what you mean..you could try using a LinearLayout as the parent Viewgroup and for each button set width to 0dip and layout_weight to 1; something like this:
That should work since the parent viewgroup (LinearLayout) has :
I hope this works.