Sometimes developer lots of time expand during minor things, just like here.When try put button, images or any things in the bottom of the layout then you try relative layout not linear layout, because in relative layout gives you very flexibility to put every part of layout.
Layout File:
Output looks like:
Most relevant example of Relative Layout in developer.android.com.
Have fun with code and Happy Coding !!!
RelativeLayout
is a view group that displays child views in relative
positions. The position of each view can be specified as relative to sibling elements (such as to
the left-of or below another view) or in positions relative to the parent RelativeLayout
area (such as aligned to the bottom, left of center).(From developer.android.com)Layout File:
<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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:text="Top Title" android:id="@+id/TextView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true"> </TextView> <RelativeLayout android:id="@+id/InnerRL" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" > <Button android:text="Submit" android:id="@+id/Button" android:layout_alignParentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> <EditText android:id="@+id/EditText" android:layout_width="fill_parent" android:layout_toLeftOf="@id/Button" android:layout_height="wrap_content"> </EditText> </RelativeLayout> </RelativeLayout>
Output looks like:
Most relevant example of Relative Layout in developer.android.com.
Have fun with code and Happy Coding !!!
0 comments
Posts a comment