I want to create a layout like below.
For that, I have using the code. It is ok if the textWoundTypeDetails text is small, but it the text is large, it is pushing the image away from the screen and text fills the total width.
<TextView
android:id="#+id/textWoundType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:padding="5dp"
android:text="#string/wound_screener" />
<ImageView
android:id="#+id/closebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_alignParentRight="true"
android:src="#drawable/buttonclose" />
<ImageView
android:id="#+id/imgWoundType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/textWoundTypeDetails"
android:layout_below="#id/textWoundType"
android:src="#drawable/article_noimg" />
<TextView
android:id="#+id/textWoundTypeDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/textWoundType"
android:padding="5dp"
android:text="A wound caused by superficial damage to the skin, no deeper than the epidermis. It is less severe than a laceration, and bleeding, if present, is minimal." />
How to solve this problem?
Try Below Code . I hope its help you .
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<TextView
android:id="#+id/textWoundType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="left"
android:layout_weight="1"
android:padding="5dp"
android:text="SCRAPES" />
<ImageView
android:id="#+id/closebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<ImageView
android:id="#+id/imgWoundType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textWoundTypeDetails"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:padding="5dp"
android:text="A wound caused by superficial damage to the skin, no deeper than the epidermis. It is less severe than a laceration, and bleeding, if present, is minimal." />
</LinearLayout>
</LinearLayout>
Related
I am doing some Android Studio courses. As part of this I am working on a mock-up music player app. The app should be mostly XML as not functionality needs to be added.
I am trying to build e Discover (new music) screen, where you have media like views. To do this, I want to implement an HorizontalScrollView.
The problem is that my scroll view doesn't move. The xml code looks fine to me and I also googled this but did not find anything that would help my situation.
Would very much appreciate some clarification on this. Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.alexcojocaru.vibes.Discover">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Recommendations"
android:textColor="#cc3300" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
android:padding="5px"
android:scrollbars="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:padding="5px"
android:src="#drawable/bear" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="My Name is Bear"
android:textColor="#000000"
android:textSize="11sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Nahko"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="13px">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:padding="6px"
android:src="#drawable/omam" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Beneath The Skin"
android:textColor="#000000"
android:textSize="11sp" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Of Monsters and Men"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="13px">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:padding="6px"
android:src="#drawable/jmj" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Essential Recollection"
android:textColor="#000000"
android:textSize="11sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Jean-Michel Jarre"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="13px">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:padding="6px"
android:src="#drawable/ram" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Random Access Memories"
android:textColor="#000000"
android:textSize="11sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Daft Punk"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</LinearLayout>
I ran the above code and it works by default.
I think the problem is that if the layout fits fully on screen then you might not be able to see the scroll.
Suggesting to test on a smaller screen.
P.S:Not enough rep for comments.
Please change HorizontalScrollView as follows
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:padding="5px"
android:scrollbars="horizontal">
Here is the situation :
I'm only using LinearLayouts (see code below), and I need the right box to be always stuck to the far right side of the screen. If i use my device in portrait mode, it's fine, but when i turn to landscape or simply go on a larger device, its just ugly.
What can I do? I've tried a 100 things with gravity/layout_gravity/relative layouts and it just does not work.
Note :
This will end as a row in a list.
The problematic linear layout contains two textview which are pretty small (~30dp wide) and on top of each other.
Here is the code for the above screenshot :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp" >
<ImageView
android:id="#+id/imgCtrl"
android:layout_width="68px"
android:layout_height="68px"
android:layout_gravity="center"
android:contentDescription="#string/imgTransport"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:id="#+id/lbDir"
android:layout_width="180dp"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:layout_weight="8"
android:hint="TestValueForDir"
android:paddingLeft="5dp"
android:textSize="18sp" />
<TextView
android:id="#+id/lbStop"
android:layout_width="180dp"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_weight="8"
android:hint="TestValueForStop"
android:paddingLeft="5dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:id="#+id/lbTime"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:gravity="right"
android:paddingLeft="20dp"
android:textSize="15sp" />
<TextView
android:id="#+id/txRating"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="right"
android:gravity="center"
android:textSize="15sp"
android:textColor="#android:color/white" />
</LinearLayout>
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp" >
<ImageView
android:id="#+id/imgCtrl"
android:layout_width="68dp"
android:layout_height="68dp"
android:contentDescription="#string/imgTransport"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:id="#+id/lbDir"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:hint="TestValueForDir"
android:paddingLeft="5dp"
android:textSize="18sp" />
<TextView
android:id="#+id/lbStop"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:hint="TestValueForStop"
android:paddingLeft="5dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
android:gravity="center_vertical|right">
<TextView
android:id="#+id/lbTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:textSize="15sp" />
<TextView
android:id="#+id/txRating"
android:layout_width="25dp"
android:layout_height="25dp"
android:textSize="15sp"
android:textColor="#android:color/white" />
</LinearLayout>
</LinearLayout>
I have a view TextViews and a WebView which I want to scull as a unit, instead of the WebView scrolling when required because of the content length. This is probably something simple, but I don't seem to be able to get it to work, as at all times the WebView has a scrollbar.
This is my Layout file:
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageView"
android:src="#drawable/background_tablet"
android:scaleType="centerCrop"
android:contentDescription="#string/background_image" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/list_background_overlay">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="#color/list_background_overlay"
android:baselineAligned="false">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/author"
android:id="#+id/article_view_author"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/title"
android:id="#+id/article_titleView" android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/site"
android:id="#+id/article_view_site"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/date_unknown"
android:id="#+id/article_view_date"
android:gravity="right"/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:background="#color/list_background_overlay"
android:id="#+id/article_mediaLayout"
android:padding="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/duration_default"
android:id="#+id/article_duration"
android:gravity="left"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/play"
android:id="#+id/article_playBttn"
android:layout_alignTop="#+id/article_preview"
android:layout_centerInParent="true"/>
<ImageView
android:layout_width="100dp"
android:layout_height="50dp"
android:id="#+id/article_preview"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:paddingRight="20dp"
android:contentDescription="#string/preview_image" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginLeft="512dp"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:id="#+id/relativeLayout">
</RelativeLayout>
</RelativeLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="15dp"
android:id="#+id/article_filler">
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/list_background_overlay"
android:paddingTop="20dp"
android:paddingBottom="20dp">
<WebView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/article_contentView" android:layout_gravity="center_horizontal"
android:padding="10dp"
android:paddingTop="30dp"
android:paddingBottom="20dp"/>
</FrameLayout>
Webview has a internal scroller. Because of that it's not a good option to wrap it in another scrollview. I don't know how complex your HTML is or whether it's a choice in your case anyway, but maybe you should think about to show it in a pure textview as discussed here: How to display HTML in TextView?
i'm working on a LinearLayout but unfortunately it's not working as it should.
The goal is to have a LinearLayout with two TextViews (one placed below the other) on the left side, and an ImageView on the right side.
The ImageView should be as big as possible, the TextViews should take the remaining space.
At the moment my layout XML is like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_linearlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:background="#drawable/background" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="2dp"
android:orientation="vertical" >
<TextView
android:id="#+id/layout1label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:singleLine="true"
android:text="1234"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/layout2label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1234_label2"
android:textSize="14dp" />
</LinearLayout>
<ImageView
android:id="#+id/layout_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_margin="2dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/ic_launcher" />
The part that isn't working: If the text in the TextViews is "too long", the ImageView gets shrinked. I want it exactly the other way round.
Any solutions?
It would be more efficient to use RelativeLayout instead of LinearLayout. Then you can place your views without having to nest layouts:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/image"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
/>
<TextView
android:id="#+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/image"
android:layout_below="#+id/title"
/>
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
/>
</RelativeLayout>
By arranging the TextViews to be relative to the ImageView instead of the other way around, the ImageView takes priority for the space, and the text works with the remainder.
this might be help to you
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_linearlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:background="#drawable/background" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/layout1label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:singleLine="true"
android:text="1234"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/layout2label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1234_labj hairu iue rel2"
android:textSize="14dp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<ImageView
android:id="#+id/layout_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_margin="2dp"
android:adjustViewBounds="true"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
A little modification to Kirans Code..worked for me
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/layout1label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:singleLine="true"
android:text="Name: BalaVishnu"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="#+id/layout_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:adjustViewBounds="true"
android:src="#drawable/edit_icon" />
</LinearLayout>
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