Relative layout on wrap content getting fullscreen due to circular dependency - android

I am pasting the layout below.
It have outer Relative layout, and inside it there are two layouts whose ids are l_first(linear layout) and slider(relative layout). THis slider layout is a layout I want aaligned to the bottom of the device screen and should take the height of the contents(several layouts and views) inside it. bottom of l_first should be positioned between top of the screen and top of slider.
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.example.raw.myapp.NewActivity"
android:background="#f2f2f2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/l_first">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:weightSum="1"
android:id="#+id/slider"
android:background="#e6e6e6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Rental"
android:layout_above="#+id/l_ten_ow"
android:id="#+id/t_rental"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:textColor="#000000"
android:textIsSelectable="true" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ten_ow">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a tenant"
android:id="#+id/btn1"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:textColor="#008000" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a owner"
android:id="#+id/btn2"
android:layout_gravity="center_vertical"
android:layout_weight="0.5" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype_label"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype"
android:paddingBottom="10dp"
android:visibility="visible">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_home"
android:src="#drawable/home1"
android:background="#00000000"
android:nestedScrollingEnabled="false" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_shop"
android:src="#drawable/shop"
android:background="#00000000" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_industry"
android:src="#drawable/industrial"
android:background="#00000000"
android:layout_weight="0.25" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_office"
android:src="#drawable/office"
android:background="#00000000"
android:layout_weight="0.25" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/r_p_subtype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype_label"
android:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="home"
android:id="#+id/textView3"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="shop"
android:id="#+id/sho"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="industrial"
android:id="#+id/ind"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="office"
android:id="#+id/textView6"
android:layout_weight="0.25"
android:textAlignment="center" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_budget"
android:id="#+id/r_p_subtype">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="#+id/btn_oye"
android:id="#+id/l_budget">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Budget"
android:id="#+id/budget"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10k"
android:id="#+id/textView4"
android:layout_below="#+id/budget"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/seekBar"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/budget"
android:layout_toRightOf="#+id/budget"
android:indeterminate="false"
android:progressTint="#39ac73"
android:thumb="#drawable/home" />
</RelativeLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:text="Oye"
android:id="#+id/btn_oye"
android:background="#39ac73"
android:clickable="true"
android:contextClickable="true" />
</RelativeLayout>

To reach your goal you should use a linear layout
make it like this :
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.example.raw.myapp.NewActivity"
android:background="#f2f2f2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/l_first"
android:layout_weight="1">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/slider"
android:orientation="vertical"
android:gravity="bottom"
android:background="#e6e6e6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Rental"
android:layout_above="#+id/l_ten_ow"
android:id="#+id/t_rental"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:textColor="#000000"
android:textIsSelectable="true" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ten_ow">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a tenant"
android:id="#+id/btn1"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:textColor="#008000" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a owner"
android:id="#+id/btn2"
android:layout_gravity="center_vertical"
android:layout_weight="0.5" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype_label"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype"
android:paddingBottom="10dp"
android:visibility="visible">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_home"
android:src="#drawable/home1"
android:background="#00000000"
android:nestedScrollingEnabled="false" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_shop"
android:src="#drawable/shop"
android:background="#00000000" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_industry"
android:src="#drawable/industrial"
android:background="#00000000"
android:layout_weight="0.25" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_office"
android:src="#drawable/office"
android:background="#00000000"
android:layout_weight="0.25" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/r_p_subtype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype_label"
android:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="home"
android:id="#+id/textView3"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="shop"
android:id="#+id/sho"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="industrial"
android:id="#+id/ind"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="office"
android:id="#+id/textView6"
android:layout_weight="0.25"
android:textAlignment="center" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_budget"
android:id="#+id/r_p_subtype">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="#+id/btn_oye"
android:id="#+id/l_budget">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Budget"
android:id="#+id/budget"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10k"
android:id="#+id/textView4"
android:layout_below="#+id/budget"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/seekBar"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/budget"
android:layout_toRightOf="#+id/budget"
android:indeterminate="false"
android:progressTint="#39ac73"
android:thumb="#drawable/home" />
</RelativeLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:text="Oye"
android:id="#+id/btn_oye"
android:background="#39ac73"
android:clickable="true"
android:contextClickable="true" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
There are two important notes :
Your linear layout should have gravity bottom, it means it calculate the height from the bottom.
the view which you want to get the rest of space should have weight of 1 !!!

Related

(Android studio) ScrollView won't scroll all the way to the bottom

im trying to put a scroll view inside a frame layout. My scroll view is not scrolling all the way to bottom. this is my xml code. It is working when i give a padding to scroll view. but i need a better answer. because giving a padding will make a white margin below my application. Thank you!
<FrameLayout 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="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
// this is your first layout to put the big image
// use src or backgroud image as per requirement
<LinearLayout
android:background="#drawable/bg"
android:layout_width="match_parent"
android:layout_height="180dp">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageView"
android:background="#drawable/overly" />
</LinearLayout>
// this is your bottom layout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffc9c9c9"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:id="#+id/relativeLayout"
android:layout_marginTop="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Anna Huffmunster"
android:id="#+id/textView2"
android:textStyle="bold"
android:textSize="20dp"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:paddingTop="40dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Colombo Sri lanka"
android:id="#+id/txt_location"
android:textSize="15dp"
android:gravity="center"
android:textStyle="italic"
android:textColor="#696969"
android:paddingBottom="7dp"
android:paddingTop="5dp"
android:layout_below="#+id/textView2"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollView"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="#+id/relativeLayout"
android:layout_marginTop="12dp"
android:id="#+id/relativeLayout2">
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/imageButton"
android:background="#drawable/call_button"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/imageButton2"
android:background="#drawable/chat_button"
android:layout_alignParentTop="true"
android:layout_toStartOf="#+id/imageButton"
android:layout_marginRight="30dp" />
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/imageButton3"
android:background="#drawable/location_button"
android:layout_alignParentTop="true"
android:layout_toEndOf="#+id/imageButton"
android:layout_marginLeft="30dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/relativeLayout2"
android:layout_alignParentStart="true"
android:layout_marginTop="12dp"
android:id="#+id/relativeLayout3">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="“Live each day as if your life had just begun.” "
android:id="#+id/txt_status"
android:textColor="#ffd9162d"
android:textSize="12dp"
android:textStyle="italic"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/relativeLayout3"
android:layout_alignParentStart="true">
<TextView
android:text="Birthday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:textSize="12sp"
android:layout_marginStart="75dp"
android:layout_marginTop="23dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:textColor="#000" />
<TextView
android:text="19 MAR 1992"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView4"
android:inputType="date"
android:layout_marginEnd="79dp"
android:textSize="12sp"
android:layout_alignBaseline="#+id/textView3"
android:layout_alignBottom="#+id/textView3"
android:layout_alignParentEnd="true" />
<TextView
android:text="Profession"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView5"
android:layout_below="#+id/textView3"
android:layout_alignStart="#+id/textView3"
android:layout_marginTop="20dp"
android:textColor="#000"
android:textSize="12sp" />
<TextView
android:text="Software Engineer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView6"
android:textSize="12sp"
android:maxWidth="20dp"
android:layout_alignTop="#+id/textView5"
android:layout_alignStart="#+id/textView4"
android:layout_alignEnd="#+id/textView4" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true">
<TextView
android:text="dgsdfsdfdfsdfsdfvv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView8"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<TextView
android:text="dgsdfsdfdfsdfsdfvv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView11"
android:layout_below="#+id/textView8"
android:layout_alignParentStart="true" />
<TextView
android:text="dgsdfsdfdfsdfsdfvv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView9"
android:layout_below="#+id/textView11"
android:layout_alignParentStart="true" />
<TextView
android:text="dgsdfsdfdfsdfsdfvv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView10"
android:layout_below="#+id/textView9"
android:layout_alignParentStart="true" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
// This is the imageview which overlay the first LinearLayout
<ImageView
android:layout_width="122dp"
android:layout_height="122dp"
android:src="#drawable/circle_profile_pic"
android:adjustViewBounds="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="100dp"
android:background="#drawable/stroke"/>

moving a specific child layout

i have this layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="#color/black_30">
<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:id="#+id/toolbarAnnouncement"
android:theme="#style/ToolBarStyle"
android:elevation="5dp"
android:textAlignment="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_gravity="center"
android:id="#+id/toolbar_title"
android:textSize="20sp"
android:textStyle="bold"
android:background="#00000000"
android:textColor="#ffffff" />
</android.support.v7.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="15"
android:id="#+id/channelContainer"
android:orientation="horizontal"
android:layout_below="#+id/toolbarAnnouncement"
android:background="#color/black_30">
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="To :"
android:id="#+id/textView16"
android:textSize="20sp"
android:paddingLeft="5dp"
android:layout_gravity="center_vertical" />
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="11"
android:id="#+id/chipViewLayout"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<com.plumillonforge.android.chipview.ChipView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/buttonChannelSelectorAnnouncement"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="left"
android:padding="5dp"
android:minHeight="90dp" />
</RelativeLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:id="#+id/buttonRemoveChannel"
android:background="#android:drawable/ic_menu_close_clear_cancel"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage1"
android:layout_below="#+id/channelContainer"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach1"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#drawable/location" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attached."
android:id="#+id/textViewAttach1"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach1"
android:layout_toEndOf="#+id/imageViewAttach1"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remove"
android:id="#+id/buttonAttach1"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach1"
android:layout_above="#+id/textViewAttach1"
android:layout_alignLeft="#+id/textViewAttach1"
android:layout_toLeftOf="#+id/buttonAttach1"
android:layout_toStartOf="#+id/buttonAttach1"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="100" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage2"
android:layout_below="#+id/attacheImage1"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach2"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#android:drawable/sym_def_app_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attaching..."
android:id="#+id/textViewAtttach2"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach2"
android:layout_toEndOf="#+id/imageViewAttach2"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:id="#+id/buttonAttach2"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach2"
android:layout_above="#+id/textViewAtttach2"
android:layout_alignLeft="#+id/textViewAtttach2"
android:layout_toLeftOf="#+id/buttonAttach2"
android:layout_toStartOf="#+id/buttonAttach2"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="77" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage3"
android:layout_below="#+id/attacheImage2"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach3"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#drawable/icon_admin" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attaching..."
android:id="#+id/textViewAttach3"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach3"
android:layout_toEndOf="#+id/imageViewAttach3"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:id="#+id/buttonAttach3"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach3"
android:layout_above="#+id/textViewAttach3"
android:layout_alignLeft="#+id/textViewAttach3"
android:layout_toLeftOf="#+id/buttonAttach3"
android:layout_toStartOf="#+id/buttonAttach3"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="43" />
</RelativeLayout>
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:inputType="textMultiLine"
android:ems="10"
android:fitsSystemWindows="true"
android:id="#+id/editText"
android:hint="write from here..."
android:gravity="top"
android:padding="5dp"
android:layout_above="#+id/relativeLayout4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_below="#+id/attacheImage3"
android:background="#ffffff" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#color/button_material_light"
android:id="#+id/relativeLayout4">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="Image"
android:id="#+id/buttonAddImage"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="Send"
android:id="#+id/button2"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
and in my layout when i start editing my editText every other layout moves up with keyboard but not the layout that is on bottom(with 2 buttons), i want it to move up too , so that it can be visible while editing my editText
any idea how i can i do this ?? my manifest for my activity :
<activity android:name=".myActivity"
android:theme="#style/AppTheme.NoActionBar"/>
what i actually need looks like this :
SEE THAT THING ON THE BOTTOM IN IOS WE CALL IT INPUT ACCESSORY
and when editing starts :
THAT LAYOUT MOVES UP WITH KEYBOARD
and what i have is this :
and when editing starts :
Try to use that new XML Layout File:
<?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"
android:animateLayoutChanges="true"
android:background="#color/black_30">
<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:id="#+id/toolbarAnnouncement"
android:elevation="5dp"
android:theme="#style/ToolBarStyle"
android:textAlignment="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_gravity="center"
android:id="#+id/toolbar_title"
android:textSize="20sp"
android:textStyle="bold"
android:background="#00000000"
android:textColor="#ffffff" />
</android.support.v7.widget.Toolbar>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:weightSum="15"
android:id="#+id/channelContainer"
android:orientation="horizontal"
android:layout_below="#+id/toolbarAnnouncement"
android:background="#color/black_30"
android:layout_weight="0.20">
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="To :"
android:id="#+id/textView16"
android:textSize="20sp"
android:paddingLeft="5dp"
android:layout_gravity="center_vertical" />
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="11"
android:id="#+id/chipViewLayout"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<com.plumillonforge.android.chipview.ChipView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/buttonChannelSelectorAnnouncement"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="left"
android:padding="5dp"
android:minHeight="90dp" />
</RelativeLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:id="#+id/buttonRemoveChannel"
android:background="#android:drawable/ic_menu_close_clear_cancel"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage1"
android:layout_below="#+id/channelContainer"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach1"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#drawable/location" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attached."
android:id="#+id/textViewAttach1"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach1"
android:layout_toEndOf="#+id/imageViewAttach1"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remove"
android:id="#+id/buttonAttach1"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach1"
android:layout_above="#+id/textViewAttach1"
android:layout_alignLeft="#+id/textViewAttach1"
android:layout_toLeftOf="#+id/buttonAttach1"
android:layout_toStartOf="#+id/buttonAttach1"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="100" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage2"
android:layout_below="#+id/attacheImage1"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach2"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#android:drawable/sym_def_app_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attaching..."
android:id="#+id/textViewAtttach2"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach2"
android:layout_toEndOf="#+id/imageViewAttach2"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:id="#+id/buttonAttach2"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach2"
android:layout_above="#+id/textViewAtttach2"
android:layout_alignLeft="#+id/textViewAtttach2"
android:layout_toLeftOf="#+id/buttonAttach2"
android:layout_toStartOf="#+id/buttonAttach2"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="77" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage3"
android:layout_below="#+id/attacheImage2"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach3"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#drawable/icon_admin" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attaching..."
android:id="#+id/textViewAttach3"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach3"
android:layout_toEndOf="#+id/imageViewAttach3"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:id="#+id/buttonAttach3"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach3"
android:layout_above="#+id/textViewAttach3"
android:layout_alignLeft="#+id/textViewAttach3"
android:layout_toLeftOf="#+id/buttonAttach3"
android:layout_toStartOf="#+id/buttonAttach3"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="43" />
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.70">
<EditText
android:layout_width="match_parent"
android:layout_height="0dp"
android:inputType="textMultiLine"
android:fitsSystemWindows="true"
android:id="#+id/editText"
android:hint="write from here..."
android:gravity="top"
android:padding="5dp"
android:background="#ffffff"
android:ems="10"
android:layout_weight="0.80"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#color/button_material_light"
android:id="#+id/relativeLayout4">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="Image"
android:id="#+id/buttonAddImage"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="Send"
android:id="#+id/button2"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
This is because of you set android:layout_alignParentBottom="true" to relativeLayout4 this won't allow it to scroll upwards. Set Top margin according to your needs or Take Linearlayout and adjust layout by weightsum property and layout_weight property.

Android how to design the xml about the UI

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>

split relative layout into two equal parts using linear layouts

I have a relative layout which contains two linear layouts. I want these two linear layouts to be placed in either halves of the relative layout containing them i.e. one to be positioned at top half and other at bottom half. Can anyone here help me with this. Here is the xml:
<RelativeLayout
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:background="#drawable/oneeventbkg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/Top_half_layout">
<ImageView
android:id="#+id/update_sn_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp" />
<TextView
android:id="#+id/update_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageView
android:id="#+id/update_message_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/update_sn_icon"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp" />
<TextView
android:id="#+id/update_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/update_message_pic"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:maxHeight="400dp"
android:scrollbars="vertical"
android:textColor="#android:color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/bottom_half_layout">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_after"
android:visibility="invisible">
<TextView
android:id="#+id/toggle_like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/toggle_comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
<ListView
android:id="#+id/likes_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_below="#id/toggle_after"
android:padding="20dp"
/>
<ListView
android:id="#+id/comments_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_below="#id/toggle_after"
android:padding="20dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#id/comments_list"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_content"
android:layout_alignParentBottom="true">
<TextView
android:id="#+id/like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Try this..
<LinearLayout
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:background="#drawable/oneeventbkg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/Top_half_layout">
// Your Codes
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/bottom_half_layout">
// Your Codes
</LinearLayout>
</LinearLayout>
EDIT
<LinearLayout
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:background="#drawable/oneeventbkg" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/Top_half_layout">
// Your Codes
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/bottom_half_layout">
// Your Codes
</RelativeLayout>
</LinearLayout>
// Try this way,hope this will help you to solve your problem...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/oneeventbkg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/Top_half_layout"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/update_sn_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp" />
<TextView
android:id="#+id/update_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:textColor="#android:color/white"
android:layout_gravity="right"
android:textSize="14sp" />
</LinearLayout>
<ImageView
android:id="#+id/update_message_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp" />
<TextView
android:id="#+id/update_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:maxHeight="400dp"
android:scrollbars="vertical"
android:textColor="#android:color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/bottom_half_layout"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_after"
android:visibility="invisible">
<TextView
android:id="#+id/toggle_like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/toggle_comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
<ListView
android:id="#+id/likes_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:padding="20dp" />
<ListView
android:id="#+id/comments_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:padding="20dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_content">
<TextView
android:id="#+id/like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

Aligning the ImageView to left the text view to center and checkbox to most right in android xml

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>

Categories

Resources