Here I am trying to display 4 ImageViews in two different linear layouts enclosed in a parent layout (with vertical orientation). But there seems to be a mismatch in heights. How can I resolve this?
Here is my xml code snippet:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/empinfo_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_emp_info"
android:gravity="right"
android:src="#drawable/employee_info" />
<ImageView
android:id="#+id/leaveinfo_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:contentDescription="#string/Homescreen_leave_info"
android:gravity="left"
android:src="#drawable/leave_info" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/holidays_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_holidays"
android:src="#drawable/holidays" />
<ImageView
android:id="#+id/leavereq_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:contentDescription="#string/Homescreen_leave_req"
android:gravity="left"
android:src="#drawable/leave_request" />
</LinearLayout>
NOTE: The dimensions of all the images are same.
Use this code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/empinfo_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/Homescreen_emp_info"
android:layout_marginRight="5dp"
android:gravity="right"
android:src="#drawable/employee_info" />
<ImageView
android:id="#+id/leaveinfo_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:contentDescription="#string/Homescreen_leave_info"
android:gravity="left"
android:src="#drawable/leave_info" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/holidays_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_holidays"
android:src="#drawable/holidays" />
<ImageView
android:id="#+id/leavereq_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:contentDescription="#string/Homescreen_leave_req"
android:gravity="left"
android:src="#drawable/leave_request" />
</LinearLayout>
image view set size width and heigth following bellow
<ImageView
android:id="#+id/leaveinfo_logo"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:contentDescription="#string/Homescreen_leave_info"
android:gravity="left"
android:src="#drawable/leave_info" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="2"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:weightSum="2"
android:orientation="horizontal" >
<ImageView
android:id="#+id/empinfo_logo"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_emp_info"
android:gravity="right"
android:src="#drawable/employee_info" />
<ImageView
android:id="#+id/leaveinfo_logo"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:contentDescription="#string/Homescreen_leave_info"
android:gravity="left"
android:src="#drawable/leave_info" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:weightSum="2"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/holidays_logo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_holidays"
android:src="#drawable/holidays" />
<ImageView
android:id="#+id/leavereq_logo"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:contentDescription="#string/Homescreen_leave_req"
android:gravity="left"
android:src="#drawable/leave_request" />
</LinearLayout>
</LinearLayout>
Related
My scollview is not scrolling. I tried putting the scrollView inside a linear layout but still not working. I am trying the scroll view in landscape mode.Also bonus question, is there a layout that i can wrap my code into so that i can have my app be perfect on all screen sizes from small screen to big tablets.
<ScrollView 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:background="#drawable/bg"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="110dp"
android:padding="10dp"
android:weightSum="2">
<LinearLayout
android:id="#+id/number"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="0dp"
android:background="#color/category_colors"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/numbers1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NUMBERS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout9"
android:layout_marginBottom="0dp"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:background="#color/category_colors"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1"
tools:ignore="RtlCompat">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/family1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FAMILY"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/number"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/number"
android:background="#color/category_home"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1"
android:layout_toRightOf="#+id/number">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/colors1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COLORS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout8"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout7"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/linearLayout7"
android:layout_toRightOf="#+id/linearLayout7"
android:background="#color/category_home"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/nouns1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VERBS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout9"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_below="#+id/linearLayout7"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/linearLayout8"
android:layout_toStartOf="#+id/linearLayout8"
android:background="#color/category_colors"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/verbs1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NOUNS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout10"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout9"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/linearLayout9"
android:layout_toRightOf="#+id/linearLayout9"
android:background="#color/category_colors"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/phrases1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PHRASES"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
Try this as per your layout use HorizontalScrollView
<HorizontalScrollView 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:background="#color/colorPrimary"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="110dp"
android:padding="10dp"
android:weightSum="2">
<LinearLayout
android:id="#+id/number"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="0dp"
android:background="#color/cardview_shadow_end_color"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NUMBERS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout9"
android:layout_marginBottom="0dp"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:background="#color/colorRed"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1"
tools:ignore="RtlCompat">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FAMILY"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/number"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/number"
android:background="#color/colorRed"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1"
android:layout_toRightOf="#+id/number">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COLORS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout8"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout7"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/linearLayout7"
android:layout_toRightOf="#+id/linearLayout7"
android:background="#color/colorRed"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VERBS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout9"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_below="#+id/linearLayout7"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/linearLayout8"
android:layout_toStartOf="#+id/linearLayout8"
android:background="#color/cardview_shadow_end_color"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NOUNS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout10"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout9"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/linearLayout9"
android:layout_toRightOf="#+id/linearLayout9"
android:background="#color/colorRed"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PHRASES"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</HorizontalScrollView>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
tools:context="com.MainActivity"
android:weightSum="4"
android:orientation="vertical"
android:background="#EDEDED">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#db4437"
android:weightSum="2"
android:orientation="vertical"
>
<ImageView
android:id="#+id/imgHeader"
android:layout_height="80dp"
android:layout_width="200dp"
android:src="#drawable/cruise"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="1"/>
<TextView
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Header"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:singleLine="true"
android:textAlignment="center"
android:layout_gravity="center_horizontal|center_vertical"
/>
</LinearLayout>
<LinearLayout android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginTop="-30dp"
android:background="#android:color/white"
android:orientation="vertical"
android:weightSum="3"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:elevation="30dp"
>
<EditText
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/textbox"
android:textColor="#android:color/black"
android:drawableStart="#drawable/user_male"
android:drawableLeft="#drawable/user_male"
android:adjustViewBounds="true"
android:maxHeight="10dp"
android:maxWidth="10dp"
android:scaleType="fitCenter"
android:hint="Email..." />
<EditText
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/textbox"
android:textColor="#android:color/black"
android:drawableStart="#drawable/user_male"
android:drawableLeft="#drawable/user_male"
android:adjustViewBounds="true"
android:maxHeight="20dp"
android:maxWidth="20dp"
android:hint="Password..." />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:orientation="horizontal"
android:background="#EDEDED"
android:weightSum="2"
>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="#CCCCCC"
android:text="Forgot password?"
android:layout_marginLeft="20dp"
android:background="#android:color/transparent"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#EDEDED"
/>
<Button
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Login"
android:layout_marginRight="10dp"
android:background="#db4437"/>
</LinearLayout>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:orientation="horizontal"
android:id="#id/bottom"
>
<ImageView
android:id="#+id/bus_ruta1"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_one"
/>
<ImageView
android:id="#+id/bus_ruta2"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_twi" />
<ImageView
android:id="#+id/bus_ruta3"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_three" />
</LinearLayout>
</LinearLayout>
Im using the following code The last linear layout contains three images and I want those images to be at the bottom of the screen but it is not being fixed at the bottom. How can I be able to sort this out?
try using a RelativeLayout instead to fill the whole screen and
the android:layout_alignParentBottom attribute
Possible dublicate of How to align views at the bottom of the screen?
try using RelativeLayout. Try this.
<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"
tools:context="com.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EDEDED"
android:orientation="vertical"
android:weightSum="4"
tools:context="com.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#db4437"
android:orientation="vertical"
android:weightSum="2" >
<ImageView
android:id="#+id/imgHeader"
android:layout_width="200dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="1"
android:src="#drawable/cruise" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="1"
android:singleLine="true"
android:text="Header"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="-30dp"
android:layout_weight="1"
android:background="#android:color/white"
android:elevation="30dp"
android:orientation="vertical"
android:weightSum="3" >
<EditText
style="#style/textbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:adjustViewBounds="true"
android:drawableLeft="#drawable/user_male"
android:drawableStart="#drawable/user_male"
android:hint="Email..."
android:maxHeight="10dp"
android:maxWidth="10dp"
android:scaleType="fitCenter"
android:textColor="#android:color/black" />
<EditText
style="#style/textbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:adjustViewBounds="true"
android:drawableLeft="#drawable/user_male"
android:drawableStart="#drawable/user_male"
android:hint="Password..."
android:maxHeight="20dp"
android:maxWidth="20dp"
android:textColor="#android:color/black" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:background="#EDEDED"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="#android:color/transparent"
android:text="Forgot password?"
android:textColor="#CCCCCC" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#EDEDED" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="#db4437"
android:text="Login" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#id/bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<ImageView
android:id="#+id/bus_ruta1"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_one" />
<ImageView
android:id="#+id/bus_ruta2"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_twi" />
<ImageView
android:id="#+id/bus_ruta3"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center|bottom"
android:scaleType="fitEnd"
android:src="#drawable/vai_three" />
</LinearLayout>
</RelativeLayout>
Here android:layout_alignParentBottom="true" is key paramater.
Happy Coding.
Here I am trying to display holidays and leave request image side by side, vertically below employee info and leave info image. But somehow the holidays and leave request images are not displayed and seems to have been overlapped. How do I rectify this?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/homescreen_bg"
android:orientation="vertical" >
<ImageView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="top"
android:contentDescription="#string/Homescreen_header"
android:src="#drawable/logoheader" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/empinfo_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_emp_info"
android:src="#drawable/employee_info"/>
<ImageView
android:id="#+id/leaveinfo_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:gravity="left"
android:contentDescription="#string/Homescreen_leave_info"
android:src="#drawable/leave_info"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/holidays_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_holidays"
android:src="#drawable/holidays"/>
<ImageView
android:id="#+id/leavereq_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:gravity="left"
android:contentDescription="#string/Homescreen_leave_req"
android:src="#drawable/leave_request"/>
</LinearLayout>
</LinearLayout>
You need to change the LinearLayout height of your images to wrap_content.
Try this:
<ImageView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="top"
android:contentDescription="#string/Homescreen_header"
android:src="#drawable/logoheader" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <!-- Changes here -->
<ImageView
android:id="#+id/empinfo_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_emp_info"
android:src="#drawable/employee_info"/>
<ImageView
android:id="#+id/leaveinfo_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:gravity="left"
android:contentDescription="#string/Homescreen_leave_info"
android:src="#drawable/leave_info"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <!-- Changes here -->
<ImageView
android:id="#+id/holidays_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_holidays"
android:src="#drawable/holidays"/>
<ImageView
android:id="#+id/leavereq_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:gravity="left"
android:contentDescription="#string/Homescreen_leave_req"
android:src="#drawable/leave_request"/>
</LinearLayout>
</LinearLayout>
Try putting layout_weight on image views inside horizontal linear layout and set layout_height of linear layouts to wrap_content. Dont forget to change layout_width to 0dp. And put whole layout in ScrollView.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="top"
android:contentDescription="#string/Homescreen_header"
android:src="#drawable/logoheader" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/empinfo_logo"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_emp_info"
android:src="#drawable/employee_info"/>
<ImageView
android:id="#+id/leaveinfo_logo"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:gravity="left"
android:contentDescription="#string/Homescreen_leave_info"
android:src="#drawable/leave_info"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/holidays_logo"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_holidays"
android:src="#drawable/holidays"/>
<ImageView
android:id="#+id/leavereq_logo"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:gravity="left"
android:contentDescription="#string/Homescreen_leave_req"
android:src="#drawable/leave_request"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
Wrap the two LinearLayouts of employee info and holidays in a container layout and set the width of each one of them to android:layout_width="0dp" and the weight to android:layout_weight="0.5", So the result will be:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/homescreen_bg"
android:orientation="vertical" >
<ImageView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:contentDescription="#string/Homescreen_header"
android:gravity="top"
android:src="#drawable/logoheader" />
<LinearLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="horizontal" >
<ImageView
android:id="#+id/empinfo_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_emp_info"
android:src="#drawable/employee_info" />
<ImageView
android:id="#+id/leaveinfo_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:contentDescription="#string/Homescreen_leave_info"
android:gravity="left"
android:src="#drawable/leave_info" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="horizontal" >
<ImageView
android:id="#+id/holidays_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/Homescreen_holidays"
android:src="#drawable/holidays" />
<ImageView
android:id="#+id/leavereq_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:contentDescription="#string/Homescreen_leave_req"
android:gravity="left"
android:src="#drawable/leave_request" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
p.s. if you want the employee info and holidays logos to be under each other not side-by-side just change the container layout orientation to vertical.
below is my layout which ontain 5 butons i want to show button with equal width and height also margin of internal layout on top and below willbe same but screen show out of layout see image http://imgur.com/TBwf0gI i want to show my 5 buttons with eqal space form top and botton for all size screens but my screen show out of layout check it
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/layoutbordercolor" >
<ImageView
android:id="#+id/btnback"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingBottom="5dp"
android:paddingLeft="3dp"
android:paddingTop="10dp"
android:src="#drawable/back" />
<ImageView
android:id="#+id/bitmap"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:src="#drawable/logostar" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="12dp"
android:text="San Diego Unified"
android:textColor="#603311"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:text="SCHOOL DISTRICT"
android:textColor="#603311"
android:textSize="10sp" />
</LinearLayout>
<ImageView
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingBottom="5dp"
android:paddingTop="10dp"
android:src="#drawable/options1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="20dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:background="#drawable/layout_border"
android:orientation="vertical"
android:paddingBottom="30dp" >
<ImageView
android:id="#+id/facebook"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="45dp"
android:src="#drawable/facebook" />
<ImageView
android:id="#+id/twitter"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/twitter" />
<ImageView
android:id="#+id/farmtoschool"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/farm_to_school" />
<ImageView
android:id="#+id/takeasurvey"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/take_a_survey" />
<ImageView
android:id="#+id/test_button_image2"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginBottom="40dp"
android:layout_marginTop="15dp"
android:src="#drawable/share_this_app" />
</LinearLayout>
</LinearLayout>
try This....
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#E5E5E5"
android:weightSum="100"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="20"
android:background="#drawable/layoutbordercolor" >
<ImageView
android:id="#+id/btnback"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingBottom="5dp"
android:paddingLeft="3dp"
android:paddingTop="10dp"
android:src="#drawable/back" />
<ImageView
android:id="#+id/bitmap"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:src="#drawable/logostar" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="12dp"
android:text="San Diego Unified"
android:textColor="#603311"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:text="SCHOOL DISTRICT"
android:textColor="#603311"
android:textSize="10sp" />
</LinearLayout>
<ImageView
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingBottom="5dp"
android:paddingTop="10dp"
android:src="#drawable/options1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="80"
android:layout_marginBottom="20dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:background="#drawable/layout_border"
android:orientation="vertical"
android:paddingBottom="30dp" >
<ImageView
android:id="#+id/facebook"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="45dp"
android:src="#drawable/facebook" />
<ImageView
android:id="#+id/twitter"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/twitter" />
<ImageView
android:id="#+id/farmtoschool"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/farm_to_school" />
<ImageView
android:id="#+id/takeasurvey"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="#drawable/take_a_survey" />
<ImageView
android:id="#+id/test_button_image2"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginBottom="40dp"
android:layout_marginTop="15dp"
android:src="#drawable/share_this_app" />
</LinearLayout>
I will show you an example and you try to implement this
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/rl1">
<Button
android:id="#+id/btn1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="click"/>
<TextView
android:id="#+id/txt1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="34dp"
android:layout_toRightOf="#+id/btn1"
android:text=" some text here" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="40dp">
<Button
android:id="#+id/abc"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:fontFamily="Arial" />
<Button
android:id="#+id/abc2"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_below="#+id/abc"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:fontFamily="Arial" />
</RelativeLayout>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Button" />
</RelativeLayout>
Always try to reduce the no of layouts inside a single layout. So to use RelativeLayout which is more customizable than others for any requirements
Use padding like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="your_size"
android:background="#E5E5E5"
android:orientation="vertical" >
This should works.
I'm having troubles when tray to insert some images in a tablerow of tablelayout.
The first imageview expands the width of its own cell and the next images expands the rest of the row
How can i divide de row in five cells with equal size?
This is a snapshot of app
http://i41.tinypic.com/2dv77g6.png
This is the code of xml layout
<?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="#drawable/gradient"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:gravity="center_vertical|right"
android:orientation="horizontal" >
<ImageView
android:id="#+id/user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:contentDescription="#string/ES_user"
android:gravity="right"
android:src="#drawable/user" />
<TextView
android:id="#+id/TextUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="#string/ES_user"
android:textColor="#ffffff"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/User"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text=""
android:textColor="#ffffff"
android:textSize="16sp" />
<TextView
android:id="#+id/TextLogout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="#string/ES_logout"
android:textColor="#fc0505"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:gravity="center" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_horizontal"
android:background="#drawable/roundcorners"
android:paddingBottom="20dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:paddingTop="20dp" >
<TableRow android:layout_weight="1" >
<ImageView
android:id="#+id/Logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_horizontal"
android:layout_weight="0.5"
android:contentDescription="#string/ES_logo"
android:paddingRight="25dp"
android:src="#drawable/logotra" />
<TableLayout
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5" >
<TableRow android:layout_weight="1" >
<TextView
android:id="#+id/Textpatient"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="#string/ES_codpatient"
android:textColor="#000000"
android:textSize="15sp" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_weight="1" >
<EditText
android:id="#+id/TxtCodPatient"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="text" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/ESlanguagebtn"
android:layout_width="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/esp" />
<ImageView
android:id="#+id/ENlanguagebtn"
android:layout_width="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/en" />
<ImageView
android:id="#+id/CATlanguagebtn"
android:layout_width="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/cat" />
<ImageView
android:id="#+id/GAlanguagebtn"
android:layout_width="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/ga" />
<ImageView
android:id="#+id/EUlanguagebtn"
android:layout_width="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/eusk" />
<ImageView
android:id="#+id/PTlanguagebtn"
android:layout_width="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/por" />
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="center" >
<Button
android:id="#+id/BtnStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="#string/ES_start" />
</TableRow>
</TableLayout>
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:gravity="center|right" >
<TextView
android:id="#+id/large_appname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ES_large_appname"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
Try to set the layout of your 5 country images as below:
As you are giving your each ImageView weight then to get the best result you must have to give width of the ImageView as 0dp.
Replace your 5 country code with below code and check out.
<TableRow
android:layout_width="fill_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/ESlanguagebtn"
android:layout_width="0dp"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:background="#drawable/icon" />
<ImageView
android:id="#+id/ENlanguagebtn"
android:layout_width="0dp"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/icon" />
<ImageView
android:id="#+id/CATlanguagebtn"
android:layout_width="0dp"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/icon" />
<ImageView
android:id="#+id/GAlanguagebtn"
android:layout_width="0dp"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/icon" />
<ImageView
android:id="#+id/EUlanguagebtn"
android:layout_width="0dp"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/icon" />
<ImageView
android:id="#+id/PTlanguagebtn"
android:layout_width="0dp"
android:layout_marginRight="10dp"
android:layout_weight="0.166"
android:src="#drawable/icon" />
</TableRow>
Let me know if still any problem.
Thanks.
Change this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:gravity="center_vertical|right"
android:orientation="horizontal" >
to this
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:gravity="center_vertical|right"
android:orientation="horizontal" >