How can I align RadioButton and TextView horizontally? - android-studio

See the image... If I don't Use the RelativeLayout the output is TextView
is below RadioButton
If I use the following code to align radioButton and TextView horizontally, the radioButtons are not identified as a part of RadioGroup, which leads to multiple selections.
<RelativeLayout
android:id="#+id/relative_layout_1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView3">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="#+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:drawableLeft="#drawable/laptop_for_gaming"
android:text="#string/gaming" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="#id/radioButton3"
android:text="#string/gaming_desp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="#+id/radioButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/laptop_professional_use"
android:text="#string/business_use" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="#+id/radioButton4"
android:text="#string/business_use_desp" />
</RelativeLayout>
</RadioGroup>
</RelativeLayout>
And if I don't use the RelativeLayout they are not align horizontally instead they are one below the other.

you can use android:orientation="horizontal" on your RadioGroup

You have to close your radiogroup adding </RadioGroup> after the RadioButtons :
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView3">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="#+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:drawableLeft="#drawable/laptop_for_gaming"
android:text="#string/gaming" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="#id/radioButton3"
android:text="#string/gaming_desp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<RadioButton
android:id="#+id/radioButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:drawableLeft="#drawable/laptop_professional_use"
android:text="#string/business_use" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="#+id/radioButton4"
android:text="#string/business_use_desp" />
</RelativeLayout>
</RadioGroup>

Related

How to put NestedScrollView between LinearLayout and MaterialButton on ConstraintLayout?

This is the rough design of my activity:
On the top is a RelativeLayout which contains an ImageView and a TextView. On the middle is a NestedScrollView which contains a RecyclerView and a CardView below it. And finally a Button on the bottom. Previously it's implemented in RelativeLayout, and works OK.
Then I change it into ConstraintLayout, like this:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns: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"
android:background="#color/myapp_main_bg"
tools:context=".activity.OrderConfirmationActivity">
<RelativeLayout
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:id="#+id/rlHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imgForkDish"
android:src="#drawable/ic_fork_dish"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_marginLeft="10dp"
android:layout_toRightOf="#id/imgForkDish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Starbucks Senayan City" />
</RelativeLayout>
<androidx.core.widget.NestedScrollView
app:layout_constraintBottom_toTopOf="#id/btnOrderNow"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="#id/rlHeader"
android:id="#+id/ns_recview_orders"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/rlHeader"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recview_orders"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.cardview.widget.CardView
android:id="#+id/cvPay"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_below="#id/ns_recview_orders"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_marginTop="20dp"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/row01"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Payment Method"
android:id="#+id/tvLblPaymentMethod"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="e-wallet"
android:textStyle="bold"
android:layout_alignParentRight="true" />
</RelativeLayout>
<View
android:id="#+id/v01"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/row01"
android:layout_marginTop="10dp"
android:background="#android:color/darker_gray" />
<RelativeLayout
android:id="#+id/row02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/v01"
android:layout_marginTop="10dp">
<TextView
android:id="#+id/tvLblTotalOrder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total Order" />
<TextView
android:id="#+id/tvTotalOrder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:layout_marginTop="10dp"
android:id="#+id/row03"
android:layout_below="#id/row02"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Service Fee"
android:id="#+id/tvLblServiceFee"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:layout_marginTop="10dp"
android:id="#+id/row04"
android:layout_below="#id/row03"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total"
android:id="#+id/tvLblTotal"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tvTotal"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:layout_marginBottom="20dp"
android:layout_marginTop="2dp"
android:id="#+id/row05"
android:layout_below="#id/row04"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Include Tax"
android:layout_alignParentRight="true" />
</RelativeLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.button.MaterialButton
android:id="#+id/btnOrderNow"
android:text="Order Now"
app:layout_constraintBottom_toBottomOf="parent"
android:backgroundTint="#color/myapp_blue_btn"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.constraintlayout.widget.ConstraintLayout>
The result is:
As you can see, the NestedScrollView isn't positioned below RelativeLayout, but instead overlaps it. How to fix this?
Remove this tag from NestedScrollView:
app:layout_constraintTop_toTopOf="parent"
It is overlapping the app:layout_constraintTop_toBottomOf="#id/rlHeader" tag.

ScrollView overlapping other content in RelativeLayout

I have a drawer menu defined for my app that uses a RelativeLayout as its root.
The general structure of the menu is as follows:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:importantForAccessibility="no"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_vert_drwr_hdr"
android:layout_width="match_parent"
android:layout_height="150dp"
android:padding="8dp"
android:background="#drawable/drawer_bg"
android:orientation="vertical">
<ImageView
... />
<TextView
... />
</LinearLayout>
<LinearLayout
android:id="#+id/manage_ids"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_vert_drwr_hdr"
android:padding="8dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
... />
<ImageView
... />
</LinearLayout>
<LinearLayout
android:id="#+id/prefs_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/manage_ids"
android:padding="8dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
... />
</LinearLayout>
<ScrollView
android:id="#+id/vscroll_prefs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/prefs_section"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingBottom="8dp">
<LinearLayout
android:id="#+id/linear3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="vertical"
android:layout_gravity="start">
<Switch
android:id="#+id/switch_rem_last_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
... />
... a bunch of switches ...
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/i_div_line_top"
android:layout_width="match_parent"
android:layout_height="1dp"
android:contentDescription="#string/dividing_line"
android:paddingEnd="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingStart="10dp"
app:srcCompat="#drawable/line_box" />
<TextView
... />
<TextView
... />
<ImageView
... />
<LinearLayout
android:id="#+id/social_links"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
... />
<ImageView
... />
</LinearLayout>
<TextView
android:id="#+id/l_app_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="8dp"
android:text="#string/app_version"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="12sp"
android:textStyle="italic" />
</LinearLayout>
</RelativeLayout>
This works fine on phones with large screens, but on smaller screens the ScrollView overlaps the LinearLayout below it.
As I'm using a RelativeLayout as the root of the layout I can't use android:layout_height="0dp" and android:layout_weight="1" instead of android:layout_height="wrap_content".
Is there another way to make the ScrollView expand to fill the available space but no more?
Got it.
I gave the LinearLayout below the ScrollView and id, then in the ScrollView I defined android:layout_above="#id/layout_below_the_scrollview".
Simple when you realise just how many android:layout... options there are!

Scroll view of center aligned linear layout is wrapping top content in small resolution devices and landscape mode

Scroll view of center aligned linear layout is wrapping top content in small resolution devices as well as landscape mode too.
but when i removed the center_vertical in linear lay out it is working fine, but i want that linear layout to be in center_vertical only.
Below is my code:!
<ScrollView
android:id="#+id/bodyscrollview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fillViewport="true" >
<LinearLayout
style="#style/app_update_alert_bg"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dp"
android:orientation="vertical" >
<TextView
style="#style/app_update_alert_bg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/updateinfo1" />
<TextView
style="#style/app_update_alert_bg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/updateinfo2" />
<ImageView
style="#style/margin5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/switching_image_border"
android:src="#drawable/switching_image_sb" />
<ImageView
style="#style/margin5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/switching_image_border"
android:src="#drawable/switching_image_ucc" />
<CheckBox
android:id="#+id/chckbox_dontshow_again"
style="#style/margin5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/custom_checkbox"
android:text="#string/updateinfo_dontshow" />
<Button
android:id="#+id/btn_updatealert_confirmation"
style="#style/buttonStyle.signInButton"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:text="OK" />
</LinearLayout>
</ScrollView>
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="match_parent"
android:orientation="vertical"
android:gravity="center">
<ScrollView
android:id="#+id/bodyscrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<LinearLayout
style="#style/app_update_alert_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
style="#style/app_update_alert_bg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/updateinfo1" />
<TextView
style="#style/app_update_alert_bg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/updateinfo2"
android:layout_marginTop="5dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/switching_image_border"
android:src="#drawable/switching_image_sb"
android:layout_marginTop="5dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/switching_image_border"
android:src="#drawable/switching_image_ucc"
android:layout_marginTop="5dp"/>
<CheckBox
android:id="#+id/chckbox_dontshow_again"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/custom_checkbox"
android:text="#string/updateinfo_dontshow"
android:layout_marginTop="5dp"/>
<Button
android:id="#+id/btn_updatealert_confirmation"
style="#style/buttonStyle.signInButton"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="OK" />
</LinearLayout>
</ScrollView>
</LinearLayout>

Android relative layout doesn't scroll

I have a relative layout in my xml file inside which I have another relative layout which has all my content. My Inner relative layout is loaded with content that comes from my database.
Also I have a edittext and button at bottom for adding comments.
Now the problem is that my inner relative layout doesn't scroll when the content is more but all the contents get hidden inside the bottom edit text and button.
Here is my xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/BG"
android:paddingTop="10dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#FFFFFF"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:scrollbars="vertical" >
<TextView
android:id="#+id/discTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"
android:text="Title"
android:textColor="#77d3f1"
android:textSize="18sp" />
<TextView
android:id="#+id/discCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discTitle"
android:layout_below="#+id/discTitle"
android:layout_marginTop="20dp"
android:text="Category"
android:textColor="#77d3f1"
android:textSize="14sp" />
<TextView
android:id="#+id/discDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discCategory"
android:layout_below="#+id/discCategory"
android:layout_marginTop="20dp"
android:text="Decsription"
android:textColor="#908484"
android:textSize="16sp" />
<TextView
android:id="#+id/discTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discDescription"
android:layout_below="#+id/discDescription"
android:layout_marginTop="20dp"
android:text="yyyy mm dd hh:mm:ss"
android:textSize="10sp" />
</RelativeLayout>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:background="#drawable/commentbg"
android:ems="10"
android:hint="Type a comment..."
android:inputType="textMultiLine"
android:minHeight="40dp"
android:paddingLeft="10dp"
android:textStyle="italic" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="61dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/commentbg"
android:minHeight="40dp"
android:text="Send" />
</RelativeLayout>
Now I want the inner relative layout’s height to occupy the whole screen and has to be
scrollable when content is more.Have a look at the image below.
Thanks in advance.
Wrap it in ScrollView
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/scroll_view_layout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#FFFFFF"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:scrollbars="vertical" >
<TextView
android:id="#+id/discTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"
android:text="Title"
android:textColor="#77d3f1"
android:textSize="18sp" />
<TextView
android:id="#+id/discCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discTitle"
android:layout_below="#+id/discTitle"
android:layout_marginTop="20dp"
android:text="Category"
android:textColor="#77d3f1"
android:textSize="14sp" />
<TextView
android:id="#+id/discDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discCategory"
android:layout_below="#+id/discCategory"
android:layout_marginTop="20dp"
android:text="Decsription"
android:textColor="#908484"
android:textSize="16sp" />
<TextView
android:id="#+id/discTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discDescription"
android:layout_below="#+id/discDescription"
android:layout_marginTop="20dp"
android:text="yyyy mm dd hh:mm:ss"
android:textSize="10sp" />
</RelativeLayout>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:background="#drawable/commentbg"
android:ems="10"
android:hint="Type a comment..."
android:inputType="textMultiLine"
android:minHeight="40dp"
android:paddingLeft="10dp"
android:textStyle="italic" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="61dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/commentbg"
android:minHeight="40dp"
android:text="Send" />
</RelativeLayout>
</ScrollView>
To scroll content you need to add ScrollView. ScrollView will be parent of the layout that you want to scroll.
http://developer.android.com/reference/android/widget/ScrollView.html

How to design a list item of listview

I have a list view with Two text labels and three image buttons on each row. Visually, I want each row to look like this:
But I can't get this to work in my layout. This is what I'm doing right now. Even though the two labels are showing up ok, the buttons are not showing as I want them to.
Question
How can I align the buttons as in the mockup?
<TextView
android:id="#+id/color_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="15dip"
android:paddingLeft="5dip"
android:paddingTop="15dip"
android:textColor="#000000"
android:textSize="16dip"
android:layout_toRightOf="#+id/track_no"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignLeft="#id/shade_count"
android:layout_below="#id/shade_count"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/shade_count"
style="#style/ListSubtitleText"
android:textColor="#ff868686"
android:layout_width="0dp"
android:layout_weight="1"
android:paddingLeft="5dip"
android:singleLine="true" />
</LinearLayout>
<ImageButton
android:id="#+id/star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/star"/>
<ImageButton
android:id="#+id/share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"
android:src="#drawable/share"/>
<ImageButton
android:id="#+id/delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/delete" />
try this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dp"
android:layout_marginTop="1dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Red Color"
android:textColor="#000000"
android:paddingLeft="5dip"
android:textSize="16dip"
android:paddingTop="15dip"/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="this color has 20 shodes"
android:textColor="#ff868686"
android:paddingLeft="5dip"
android:paddingTop="15dip"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="15dip"
android:src="#drawable/star" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="15dip"
android:src="#drawable/share" />
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="15dip"
android:src="#drawable/delete" />
</LinearLayout>
</LinearLayout>
Try This:-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="1dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:paddingTop="15dip"
android:text="Red Color"
android:textColor="#000000"
android:textSize="16dip" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:paddingTop="15dip"
android:text="this color has 20 shodes"
android:textColor="#ff868686" />
</LinearLayout>
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="38dp" >
<ImageView
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/star" />
<ImageView
android:id="#+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/imageButton1"
android:src="#drawable/share" />
<ImageView
android:id="#+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/imageButton2"
android:src="#drawable/delete" />
</RelativeLayout>
</RelativeLayout>

Resources