Children in Linear Layout with equal padding - android

I am currently designing a ButtonBar with 5 buttons (they will all be ImageButtons, but for now, only 3 of them are). This is my first android project so I'm learning as I go along. I'm trying to weight each button equally, without scaling them (have equal padding rather than equal width). This is my code so far:
<LinearLayout
android:id="#+id/back"
android:orientation="horizontal"
android:layout_height="50dip"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:background="#000000"
style="#android:style/ButtonBar"
android:weightSum="5"
>
<ImageButton
android:id="#+id/info_button"
android:padding="20dp"
android:background="#drawable/info"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
/>
<Button
android:id="#+id/wishlist_button"
android:text="#string/wish_label"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:padding="20dp"
android:textSize="15dip"
android:textColor="#b7b7b7"></Button>
<Button
android:id="#+id/buy_button"
android:text="#string/buy_label"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:padding="20dp"
android:textSize="15dip"
android:textColor="#b7b7b7"/>
<ImageButton
android:id="#+id/dislike_button"
android:padding="20dp"
android:background="#drawable/dislike_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
/>
<ImageButton
android:id="#+id/like_button"
android:padding="20dp"
android:background="#drawable/like_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
/>
This is what it looks like now:
stretched weighted: http://i.imgur.com/MAfjp.png
This is what I want it to look like (closely):
non-stretched equally padded: http://i.imgur.com/vXTEy.png
Thank you for helping. I've been searching for the answer for a while and have tried so much already.

Here it is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/back"
android:orientation="horizontal"
android:layout_height="50dip"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:background="#000000"
style="#android:style/ButtonBar"
android:gravity="center"
>
<ImageButton
android:id="#+id/info_button"
android:background="#null"
android:src="#drawable/info"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
/>
<Button
android:id="#+id/wishlist_button"
android:text="#string/wish_label"
android:background="#null"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:textSize="15dip"
android:textColor="#b7b7b7"></Button>
<Button
android:id="#+id/buy_button"
android:text="#string/buy_label"
android:background="#null"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:textSize="15dip"
android:textColor="#b7b7b7"/>
<ImageButton
android:id="#+id/dislike_button"
android:background="#null"
android:src="#drawable/dislike_button"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
/>
<ImageButton
android:id="#+id/like_button"
android:background="#null"
android:src="#drawable/like_button"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
I don't know how style="#android:style/ButtonBar" is set, so if it doesn't show properly try remove it.

You could add a spacer element in between each of the images/buttons and assign the layout_weight to the spacer elements instead of the images/buttons. So it would look something like this:
<LinearLayout
android:id="#+id/back"
android:orientation="horizontal"
android:layout_height="50dip"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:background="#000000"
style="#android:style/ButtonBar"
>
<ImageButton
android:id="#+id/info_button"
android:padding="20dp"
android:background="#drawable/info"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_weight="1" />
/>
<Button
android:id="#+id/wishlist_button"
android:text="#string/wish_label"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:padding="20dp"
android:textSize="15dip"
android:textColor="#b7b7b7"></Button>
<LinearLayout
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="#+id/buy_button"
android:text="#string/buy_label"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:padding="20dp"
android:textSize="15dip"
android:textColor="#b7b7b7"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageButton
android:id="#+id/dislike_button"
android:padding="20dp"
android:background="#drawable/dislike_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageButton
android:id="#+id/like_button"
android:padding="20dp"
android:background="#drawable/like_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</LinearLayout>
This may not be the most elegant solution since it adds several views to your layout, but it's worked for me in the past.

You should consider using only image button with equal size images with equal weight inside your LinearLayout.
Regards,
Stéphane

Related

Listview is not visible with other elements on top of it

I'm trying to create UI like the attached image. My xmal code below. There is one main issue that I"m running into. I understand that I can't embed a listview within a scrollview. The problem is, because of all the stuff on top of the listview, only a small portion of the listview is shown no matter what kind of height I give the parent linearlayout.
How can I layout my UI so that the listview will be visible and can be scrolled to with other UI elements on top of it? Any suggestion is apperciated.
Thanks in advance
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bkicon"
android:id="#+id/linearLayout1">
<LinearLayout
android:orientation="horizontal"
android:minWidth="25dp"
android:minHeight="25dp"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/bkicon"
android:weightSum="4"
android:id="#+id/linearLayoutButtons">
<Button
android:text="Posts"
android:layout_width="50dp"
android:layout_height="100dp"
android:background="#drawable/mybuttonSelected"
android:layout_weight="1"
android:id="#+id/btngohomemb" />
<Button
android:text="Chat"
android:layout_width="50dp"
android:layout_height="100dp"
android:background="#drawable/mybutton"
android:layout_weight="1"
android:id="#+id/btngohomemb" />
<Button
android:text="Business"
android:layout_width="50dp"
android:layout_height="100dp"
android:background="#drawable/mybutton"
android:layout_weight="1"
android:id="#+id/btnMBRefresh" />
<Button
android:text="Resources"
android:layout_width="50dp"
android:layout_height="100dp"
android:background="#drawable/mybutton"
android:layout_weight="1"
android:id="#+id/btnMBNewMessage" />
</LinearLayout>
<Button
android:text=""
android:gravity="left|center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textColor="#000000"
android:textStyle="bold"
android:background="#drawable/mybutton"
android:id="#+id/locHeader" />
<TextView
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="left|center_vertical"
android:textColor="#000000"
android:id="#+id/locBody"
android:background="#FFFFFF" />
<TextView
android:text="\nWhat's on your mind?\n"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="left|center_vertical"
android:textColor="#ffffff"
android:id="#+id/lblWhatonyourmind"
android:background="#000000" />
<ImageView
android:src="#android:drawable/ic_menu_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
<EditText
android:inputType="textMultiLine"
android:lines="8"
android:minLines="6"
android:gravity="top|left"
android:maxLines="10"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:scrollbars="vertical"
android:id="#+id/etNewPost" />
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#drawable/bkicon"
android:weightSum="3"
android:id="#+id/linearLayoutButtons">
<Button
android:text="Add Pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/mybutton"
android:layout_weight="1"
android:id="#+id/btnPostPicture" />
<CheckBox
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/chbxRestrict" />
<Button
android:text="Post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/mybutton"
android:layout_weight="1"
android:id="#+id/btnPost" />
</LinearLayout>
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="#+id/lvPostedMsges" />
</LinearLayout>
This is happening because the heights of the elements above the Listview are taking the minimum space they need and thus leaving the small portion free for the list view, since linear layout stacks elements on after the other giving priority to the previous elements. So think about redesigning your page in a better way.

Android button height is different

I have two buttons inside a linear layout which have same properties defined. But to my surprise, both have different height. Please see the xml code below
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="5dp" >
<ImageView
android:id="#+id/imgUser"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_marginTop="10dp"
android:adjustViewBounds="true"
android:src="#drawable/default_people_thumb" />
<TextView
android:id="#+id/tvUploadHeader"
style="#style/Text.Quaternary.Small.Bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose_a_profile_photo" />
<TextView
android:id="#+id/tvDescription"
style="#style/Text.Quaternary.ExtraSmall.Bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:text="#string/photo_upload_initial" />
<Button
android:id="#+id/btnChoosePhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/login_button_selector"
android:text="#string/choose_photo_from_gallery" />
<Button
android:id="#+id/btnSkip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/login_button_selector"
android:text="#string/choose_photo_from_gallery" />
</LinearLayout>
Can you please help me to have the same height. I am wondering as to how both behaves differently. Also added includeFontPadding for the button. But no hope :(.
Your background drawables have different padding or height. check #drawable/btn_large_gray and #drawable/login_button_selector
put both the button inside linear layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="5dp" >
<ImageView
android:id="#+id/imgUser"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_marginTop="10dp"
android:adjustViewBounds="true"
android:src="#drawable/default_people_thumb" />
<TextView
android:id="#+id/tvUploadHeader"
style="#style/Text.Quaternary.Small.Bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose_a_profile_photo" />
<TextView
android:id="#+id/tvDescription"
style="#style/Text.Quaternary.ExtraSmall.Bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:text="#string/photo_upload_initial" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="5dp" >
<Button
android:id="#+id/btnChoosePhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/login_button_selector"
android:text="#string/choose_photo_from_gallery" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="5dp" >
<Button
android:id="#+id/btnSkip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/btn_large_gray"
android:text="#string/skip" />
</LinearLayout>
</LinearLayout>
and adjust both linear layouts as you like it
Try defining property android:layout_weight for each element in your LinearLayout, so they can have the same height.
For example :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="5dp" >
<ImageView
android:id="#+id/imgUser"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_weight="1"
android:layout_margin="5dp"
android:layout_marginTop="10dp"
android:adjustViewBounds="true"
android:src="#drawable/default_people_thumb" />
<TextView
android:id="#+id/tvUploadHeader"
style="#style/Text.Quaternary.Small.Bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/choose_a_profile_photo" />
<TextView
android:id="#+id/tvDescription"
style="#style/Text.Quaternary.ExtraSmall.Bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:text="#string/photo_upload_initial" />
<Button
android:id="#+id/btnChoosePhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp"
android:background="#drawable/login_button_selector"
android:text="#string/choose_photo_from_gallery" />
<Button
android:id="#+id/btnSkip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp"
android:background="#drawable/login_button_selector"
android:text="#string/choose_photo_from_gallery" />
</LinearLayout>
The idea is to give as much space to each element. Your LinearLayout contains different elements so by choosing wrap_content in the android:layout_height and android:layout_width, space available will be allocated for each element added. And as you TextViews and Buttons are not the same...
Hope it'll help
You are using different style for both the buttons,
i.e. "#style/Text.Quaternary.Small.Bold" and "#style/Text.Quaternary.ExtraSmall.Bold" you should use only one style for both buttons

making bottom bar in android

I am trying to make bottom bar that should look like below image. i.e., they should be separate only with line exactly like below image.
My output is like below image
My code:
<LinearLayout
android:id="#+id/buttonbar"
style="#android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/okButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#android:string/ok" />
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#android:string/cancel" />
</LinearLayout>
I have imported an example and it's looking like the first image. But when I used the same code in my project and tested on the same emulator, it's looking like the second one. Can some one suggest what should be done to look like in the first image?
Try this code, it will give a result like the first image.
But I did some color changes only.
Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/buttonbar"
style="#android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:orientation="horizontal" >
<Button
android:id="#+id/okButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"
android:layout_weight="1"
android:text="#android:string/ok"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"
android:layout_weight="1"
android:text="#android:string/cancel"
android:textColor="#FFFFFF" />
</LinearLayout>
Update: This is what you need.
Edited:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/buttonbar"
style="#android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:orientation="horizontal" >
<Button
android:id="#+id/okButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"
android:layout_weight="1"
android:text="#android:string/ok"
android:textColor="#FFFFFF" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ffffff" />
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"
android:layout_weight="1"
android:text="#android:string/cancel"
android:textColor="#FFFFFF" />
</LinearLayout>
Increase the size of dp as much as you want to show the difference.
try this..
<Button
android:id="#+id/okButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#android:string/ok"
style="?android:attr/borderlessButtonStyle" />
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#android:string/cancel"
style="?android:attr/borderlessButtonStyle" />
</LinearLayout>

Complex layout with same layout_margin in Android

I have a problems with my layout_margin. I want to make my layout look like that:
(with "a" is margin)
My problems is, when i build my layout in other screen size, it look like that:
How can i make it beautiful with different screen size? This is my layout:
<LinearLayout
android:id="#+id/footer_result_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/btn_recommendtion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/coodinate" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginTop="20dip"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/btn_facebook"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_margin="5dip"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/fb" />
<ImageView
android:id="#+id/btn_mixi"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_margin="5dip"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/mixi" />
</LinearLayout>
</LinearLayout>
Try using a relative layout.
Here is an example using buttons. You can swap out the values of the buttons with your image views, and adjust your margins as needed. This should center the buttons, with the same margins on any screen.
<Button
android:id="#+id/btn_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:text="BUTTON 1"
android:layout_centerHorizontal="true"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#+id/btn_1"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dip"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_margin="5dip"
android:text="BUTTON 2" />
<Button
android:id="#+id/btn_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_margin="5dip"
android:text="BUTTON 3" />
</LinearLayout>
It looks like this:
You'll need to use RelativeLayout for that.
Center button1 with android:layout_alignParentTop="true" and align it in the parent top with android:layout_centerHorizontal="true and work from there.
The code:-
<?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">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
android:layout_margin="10dip"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"/>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2"
android:layout_margin="10dip"
android:layout_alignParentLeft="true"
android:layout_below="#+id/button1"/>
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 3"
android:layout_margin="10dip"
android:layout_alignParentRight="true"
android:layout_below="#+id/button1"/>
</RelativeLayout>
Considering the a=10

relative layout problem in android

in my app i use relative layout for design.in an activity i have four buttons at bottom of the screen. my xml code(Land scape) does not suit for all device screen. it has more space between buttons as show in the figure. how to design the layout which is suit for all resolution screen (Landscape).
layout image is :
my xml:
<RelativeLayout android:id="#+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#0000FF"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_width="fill_parent"
android:layout_gravity="bottom" android:layout_alignParentBottom="true"
android:background="#drawable/applicarion_bar" android:layout_height="wrap_content"
android:id="#+id/relativeLayout4">
<ImageButton android:id="#+id/homeimageButton2"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#drawable/festival_btn" />
<ImageButton android:layout_height="wrap_content"
android:layout_toRightOf="#+id/homeimageButton2"
android:layout_marginLeft="60dp"
android:layout_width="wrap_content" android:background="#drawable/search_btn"
android:id="#+id/homeimageButton3"></ImageButton>
<TextView android:id="#+id/homecalendar4" android:text="MAR 20"
android:layout_toRightOf="#+id/homeimageButton3"
android:gravity="center"
android:textSize="10dp"
android:layout_marginLeft="60dp"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#drawable/calendar_btn" />
<ImageButton android:id="#+id/homeimageButton5"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#drawable/favorite_btn" />
</RelativeLayout>
Replace your relativeLayout4 as
<LinearLayout android:id="#+id/put_id_of_ll"
android:orientation="horizontal" android:background="#012C58"
android:paddingLeft="4.0dip" android:paddingTop="5.0dip"
android:paddingRight="4.0dip" android:paddingBottom="1.0dip"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ImageButton android:id="#+id/homeimageButton2"
android:layout_width="0.0dip"
android:text="ImageButton"
android:background="#drawable/festival_btn"
android:layout_weight="1.0"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginBottom="3dip"
android:layout_marginLeft="2dip" />
<ImageButton android:id="#+id/homeimageButton3"
android:background="#drawable/search_btn"
android:layout_width="0.0dip"
android:text="btn2"
android:layout_weight="1.0"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginBottom="3dip"
android:layout_marginLeft="2dip" />
<TextView android:id="#+id/homecalendar4" android:text="MAR 20"
android:layout_width="0.0dip"
android:layout_weight="1.0"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginBottom="3dip"
android:layout_marginLeft="2dip" />
<ImageButton android:id="#+id/homeimageButton5"
android:layout_width="0.0dip"
android:text="btn4"
android:background="#drawable/favorite_btn"
android:layout_weight="1.0"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginBottom="3dip"
android:layout_marginLeft="2dip" />
</LinearLayout>
It will work.
Happy coding :)
use linear layout instead of relative layout, use below code
<RelativeLayout android:id="#+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#0000FF"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_width="fill_parent"
android:layout_gravity="bottom" android:orientation="horizontal"
android:background="#drawable/applicarion_bar" android:layout_height="wrap_content"
android:id="#+id/relativeLayout4">
<ImageButton android:id="#+id/homeimageButton2"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/festival_btn" />
<ImageButton android:layout_height="wrap_content"
android:layout_toRightOf="#+id/homeimageButton2"
android:layout_weight="1"
android:layout_marginLeft="60dp"
android:layout_width="wrap_content" android:background="#drawable/search_btn"
android:id="#+id/homeimageButton3"></ImageButton>
<TextView android:id="#+id/homecalendar4" android:text="MAR 20"
android:layout_toRightOf="#+id/homeimageButton3"
android:gravity="center"
android:textSize="10dp"
android:layout_marginLeft="60dp"
android:layout_weight="1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#drawable/calendar_btn" />
<ImageButton android:id="#+id/homeimageButton5"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#drawable/favorite_btn" />
</LinearLayout>
</RelativeLayout>
try to use a linear layout and give equal weight to all the views.

Categories

Resources