I am confused by Android layout design. I want to achieve the layout in the following image:
But the code below is producing something like this image:
My code
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50sp"
android:layout_below="#+id/view"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#drawable/bg_shadow"
android:animateLayoutChanges="true"
android:layout_marginTop="5dp"
android:id="#+id/detailsLay">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/repeat"
android:id="#+id/repeatCheckBox"
android:longClickable="false"
android:textColor="#android:color/background_light"
android:paddingTop="15sp"
android:paddingRight="15sp"
android:paddingLeft="1sp"
android:paddingBottom="15sp" />
<TextView
android:layout_width="30dp"
android:layout_height="20sp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/sat"
android:id="#+id/satTextView"
android:layout_gravity="center_vertical|right"
android:textColor="#android:color/holo_orange_light"
android:layout_marginLeft="2sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/arrowDown"
android:src="#android:drawable/arrow_down_float"
android:layout_gravity="center_vertical" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/everyday"/>
</LinearLayout>
</LinearLayout>
This is just a Sample Xml learn from this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<CheckBox
android:id="#+id/checkBox1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="CheckBox" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
Use attributes like weight and user orientation of linearlayout.
Related
I am trying to place buttons side by side next to one another in three buttons to one row using a RelativeLayout.
This is the relative layout placed inside a linear layout with the group of buttons
main.xml
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="20px" >
</RelativeLayout>
</LinearLayout>
These are the group of button found inside the layouts
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/snap"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/shutterButton"
android:text="SNAP"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/up"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/Up"
android:text="xxxx"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/ic_action_borrow"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxx"
android:text="xxxxx"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/xxxx"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxx"
android:text="xxxx"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/xxxx"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxx"
android:text="xxxx"></Button>
OUTPUT
Please how can I place the buttons one after another in 3 buttons to one row.
Kindly assist!
Try this:
XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="20px">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="SNAP"
android:textColor="#FFFFFF"></Button>
<!--android:drawableTop="#drawable/snap"-->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="xxxx"
android:textColor="#FFFFFF"></Button>
<Button
android:id="#+id/xxxx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="xxxxx"
android:textColor="#FFFFFF"></Button>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="20px">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="xxxx"
android:textColor="#FFFFFF"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="xxxx"
android:textColor="#FFFFFF"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="xxxx"
android:textColor="#FFFFFF"
android:visibility="invisible"></Button>
</LinearLayout>
</LinearLayout>
Output will be:
the following code creates 4 buttons side by side horizontally
<LinearLayout
android:layout_marginTop="1dp"
android:layout_marginBottom="1dp"
android:id="#+id/lay"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/button1"
android:text="Button1"
android:layout_weight="1"
android:padding="5dp" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/button2"
android:text="Button2"
android:layout_weight="1"
android:padding="5dp" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/button3"
android:text="Button3"
android:layout_weight="1"
android:padding="5dp" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/button4"
android:text="Button4"
android:layout_weight="1"
android:padding="5dp" />
</LinearLayout>
You should linear layout for this kind of horizontal buttons and don't forget to make the orientation of inside LinearLayout to horizontal.
Like
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="20px" >
Then add buttons inside this linear layout, all the buttons will come side by side.
Try LinearLayout with android:orientation="horizontal". Check this below -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="20px">
<Button
android:id="#+id/shutterButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:drawableTop="#drawable/snap"
android:text="SNAP"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/Up"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:drawableTop="#drawable/up"
android:text="xxxx"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/xxxx"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:drawableTop="#drawable/ic_action_borrow"
android:text="xxxxx"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/xxxx"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:drawableTop="#drawable/xxxx"
android:text="xxxx"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/xxxx"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:drawableTop="#drawable/xxxx"
android:text="xxxx"
android:textColor="#FFFFFF" />
</LinearLayout>
Try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="20px" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/snap"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/shutterButton"
android:text="SNAP"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/up"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/Up"
android:text="xxxx"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/xxxxx"
android:layout_toStartOf="#+id/xxxxx"
android:layout_marginRight="27dp"
android:layout_marginEnd="27dp"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/ic_action_borrow"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxxx"
android:text="xxxxx"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/xxxx"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxxxx"
android:text="xxxx"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/xxxx"
android:layout_toStartOf="#+id/xxxx"
android:layout_marginRight="50dp"
android:layout_marginEnd="50dp"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/xxxx"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxx"
android:text="xxxx"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"></Button>
</RelativeLayout>
</LinearLayout>
I need to design the xml about below layout.
I try to use RelativeLayout to design, but I don't know
how to adjust the imageVivew3 in RelativeLayout.
Have anyone can teach me how to adjust the xml?
or have you nice xml design about this layout?
thank you very much.
my xml is below:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative_bg"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView1"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:layout_margin="0dp"/>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView2"
android:visibility="visible"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"/>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView3"
android:visibility="visible"
android:layout_centerVertical="true"
android:layout_below="#+id/imageView3"
android:layout_alignParentRight="true"
/>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView4"
android:layout_alignTop="#+id/textView1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="txt1"
android:id="#+id/textView1"
android:textColor="#color/white"
android:textSize="#dimen/common_size_large"
android:layout_below="#+id/imageView3"
android:layout_alignParentRight="true"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="txt2"
android:id="#+id/textView2"
android:textColor="#color/white"
android:layout_below="#+id/textView1"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
Try to LinearLayout instead of RelativeLayout..
And also use android:layout_weight atttribute ...code sample are given below... put this
code to your xml.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#android:color/white"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight=".75"
android:layout_marginTop="5dp"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="2"
android:layout_gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/gerder"
android:textSize="12sp"
android:textStyle="bold"
android:contentDescription="#string/app_name"
android:layout_gravity="center"
android:paddingLeft="10dp"
android:gravity="center"
android:textColor="#android:color/black"
android:fontFamily="#string/providerFontFamily"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<RadioGroup
android:id="#+id/radioGender"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="5dp"
>
<RadioButton
android:id="#+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/providerGenderMale"
android:checked="true" />
<RadioButton
android:id="#+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/providerGenderFemale" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="2"
android:layout_gravity="center"
>
<TextView
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#string/providerFontFamily"
android:text="#string/age_range"
android:gravity="left"
android:textSize="12sp"
android:textStyle="bold"
android:textColor="#android:color/black"
android:layout_gravity="center"
/>
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginRight="15dp"
android:prompt="#string/country_prompt"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I am making a activity layout using RelativeLayout i want the image view to be in most left and textview to be in center and checkbox to be in most right but layoutgravity and gravity is not working please can somebody help
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageViewTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:gravity="left"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textViewTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Time" />
<CheckBox
android:id="#+id/checkBoxTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:=""
android:gravity="right" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageViewCompass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:gravity="left"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textViewCompass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Compass" />
<CheckBox
android:id="#+id/checkBoxCompass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:gravity="right" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageViewMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:gravity="left"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textViewMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Map" />
<CheckBox
android:id="#+id/checkBoxMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:gravity="right" />
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageViewTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:gravity="left"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textViewTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/imageViewTime"
android:layout_weight="1"
android:gravity="center"
android:text="Time" />
<CheckBox
android:id="#+id/checkBoxTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:gravity="right" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageViewCompass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:gravity="left"
android:src="#drawable/ic_launcher" />
<CheckBox
android:id="#+id/checkBoxCompass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:gravity="right" />
<TextView
android:id="#+id/textViewCompass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/imageViewCompass"
android:layout_weight="1"
android:gravity="center"
android:text="Compass" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageViewMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:gravity="left"
android:src="#drawable/ic_launcher" />
<CheckBox
android:id="#+id/checkBoxMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:gravity="right" />
<TextView
android:id="#+id/textViewMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/imageViewMap"
android:layout_weight="1"
android:gravity="center"
android:text="Map" />
</RelativeLayout>
While developing a layout today I found some weird thing my Linear layout is not filling the available space .
//Image removed
My left layout is re-sizing according to content but i don't want that. What I want is the right edge of left hand side layout should touch the left edge of right layout.
I have tried both fill parent and wrap content with layout_weight but nothing is happening what i want is something like this.
// Image removed
My layout code :
<?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"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:paddingLeft="7dp"
android:paddingRight="7dp">
<RelativeLayout
android:id="#+id/total_top_layout"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingBottom="10dp"
android:layout_centerHorizontal="true">
<TextView
android:id="#+id/ammount_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="First Text Here"
android:textSize="20sp"
android:layout_centerVertical="true" />
<EditText
android:id="#+id/total_ammount_input"
android:layout_height="wrap_content"
android:layout_width="150dp"
android:singleLine="true"
android:layout_alignParentRight="true"
android:background="#color/hologreennewdark"
android:text="second Text"
android:layout_centerVertical="true"
android:padding="8dp"
android:gravity="center"
android:textColor="#color/WhiteSmoke" />
</RelativeLayout>
<View
android:id="#+id/divideaftertotal"
android:layout_width="#dimen/divide_width"
android:layout_height="#dimen/divider_height"
android:background="#color/YellowGreen"
android:layout_below="#+id/total_top_layout"
/>
<RelativeLayout
android:id="#+id/tens_view_top"
android:layout_below="#id/divideaftertotal"
android:layout_height="75dp"
android:layout_width="wrap_content"
>
<LinearLayout
android:id="#+id/tens_view_left"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
>
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Num1"
android:layout_centerVertical="true"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_toRightOf="#id/amount_rupee"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Num2"
android:layout_centerVertical="true"
android:textSize="25sp"
android:layout_toRightOf="#+id/multiply_sign"
android:layout_marginLeft="40dp" />
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#color/hologreendark"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
</RelativeLayout>
<View
android:id="#+id/divideaftertens"
android:layout_width="#dimen/divide_width"
android:layout_height="#dimen/divider_height"
android:background="#color/YellowGreen"
android:layout_below="#+id/tens_view_top"
/>
</RelativeLayout>
On the layout android:id="#+id/tens_view_left", you could add this 2 atributes:
android:layout_alignParentLeft="true"
so that its left side is anchored in its parent's left border, and
android:layout_toLeftOf="#id/id_from_the_linear_layout_on_the_right"
And that layout is:
<LinearLayout
android:id="#+id/id_from_the_linear_layout_on_the_right"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#color/hologreendark"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
By the way, you might need to set android:orientation="horizontal"
on the layout android:id="#+id/tens_view_top"
When using layout_weight, set the layout_width to 0dp (for horizontal orientation).
it could be like,
<LinearLayout
android:id="#+id/tens_view_left"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
>
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="horizontal"
>
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Num1"
android:layout_centerVertical="true"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_toRightOf="#id/amount_rupee"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Num2"
android:layout_centerVertical="true"
android:textSize="25sp"
android:layout_toRightOf="#+id/multiply_sign"
android:layout_marginLeft="40dp" />
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"
/>
</LinearLayout>
<LinearLayout
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#color/hologreendark"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Change the RelativeLayout to LinearLayout that contain two layout you want to have close, and add layout_weight=1 to first LinearLayout with layout_width=0dip like
<LinearLayout
android:id="#+id/tens_view_top"
android:layout_below="#id/divideaftertotal"
android:layout_height="75dp"
android:layout_width="wrap_content"
>
<LinearLayout
android:layout_weight="1"
android:id="#+id/tens_view_left"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="0dip"
>
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Num1"
android:layout_centerVertical="true"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_toRightOf="#id/amount_rupee"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Num2"
android:layout_centerVertical="true"
android:textSize="25sp"
android:layout_toRightOf="#+id/multiply_sign"
android:layout_marginLeft="40dp" />
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#FFCCDD"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
// try this i have used LinearLayout rather than RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="7dp">
<LinearLayout
android:id="#+id/total_top_layout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:paddingBottom="10dp">
<TextView
android:id="#+id/ammount_view"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="0dp"
android:text="First Text Here"
android:textSize="20sp"/>
<EditText
android:id="#+id/total_ammount_input"
android:layout_height="wrap_content"
android:layout_width="150dp"
android:singleLine="true"
android:text="second Text"
android:padding="8dp"
android:gravity="center"/>
</LinearLayout>
<View
android:id="#+id/divideaftertotal"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<LinearLayout
android:id="#+id/tens_view_left"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<LinearLayout
android:layout_height="match_parent"
android:gravity="center"
android:layout_width="0dp"
android:layout_weight="1">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:text="Num1"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:text="Num2"
android:textSize="25sp"
android:layout_marginLeft="40dp" />
</LinearLayout>
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"/>
</LinearLayout>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="match_parent"
android:layout_width="100dp"
android:text="Num3"
android:textSize="25sp"
android:gravity="center"/>
</LinearLayout>
<View
android:id="#+id/divideaftertens"
android:layout_width="match_parent"
android:layout_height="1dp"/>
</LinearLayout>
i want to add two imageViews in one layout, images i will set from galery (diferent size of image).Defaut images- all is ok. But when i set image from galery (image one)- a get a lot free space (image two)
2:
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exrcise name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/et_exrcise_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Image"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RadioButton
android:id="#+id/radio_anime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:onClick="onRadioButtonClicked"
android:text="anime" />
<RadioButton
android:id="#+id/radio_static"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:text="static" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/iv_image_one"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:scaleType="centerInside"
android:src="#drawable/btn_apply_oval_new" />
<ImageView
android:id="#+id/iv_image_two"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:scaleType="centerInside"
android:src="#drawable/btn_apply" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/btn_set_image_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="#+id/btn_set_image_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Muscle group"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="#+id/spinner_muscle_group"
android:layout_width="wrap_content"
android:layout_height="45dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/et_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tecnique"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/et_tecnique"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/btn_save_exercise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAVE" />
<Button
android:id="#+id/test_anim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
</ScrollView>
try
android:adjustViewBounds="true"
It worked for a similar problem i've had some time ago.
have you tried to set the height of both the problematic linearLayout and the imageView to wrap_content?
also, have you tried to set a weight (to 1) to the problematic linearLayout and then set its height to 0px ?