Here xml code i tried
<?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:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/home_icon"
/>
<Button
android:id="#+id/btnHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="OnHomeSelected"
/>
</LinearLayout>
<ImageView
android:id="#+id/ivnetconstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ledred"
android:layout_gravity="right"
/>
</LinearLayout>
output generated using above xml file
I want to align home image & home button to center and red circle image to right of the layout.
thanks in advance
Try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:gravity="center"
>
<ImageView
android:id="#+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/home_icon"
/>
<Button
android:id="#+id/btnHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/image1"
android:onClick="OnHomeSelected"
/>
</RelativeLayout>
<ImageView
android:id="#+id/ivnetconstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ledred"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
Change your layout like this..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="#+id/ivnetconstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/home_icon" />
<Button
android:id="#+id/btnHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:onClick="OnHomeSelected" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/btnHome"
android:gravity="center"
android:src="#drawable/ledred" />
</RelativeLayout>
use Relative Layout which provide you mutiple properties to align views.
shot try with below code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon" />
<Button
android:id="#+id/btnHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="OnHomeSelected" />
</LinearLayout>
<ImageView
android:id="#+id/ivnetconstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
Related
I'm dynamically injecting rows in a container of a fragment.
But I just can't seem to get the three image buttons aligned to the right, next to each other.
Anyone an idea?
Fragment layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scenesScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/switchLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/scenesTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/switch_title"
android:text="#string/title_switches" />
<LinearLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
</LinearLayout>
<TextView
android:id="#+id/statusText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"/>
</LinearLayout>
</ScrollView>
My row layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp">
<TextView
android:id="#+id/switch_name"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/switch_row_name"
android:text="Switch name"/>
<TextView
android:id="#+id/switch_lastSeen"
android:layout_below="#id/switch_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/switch_row_lastSeen"
android:text="#string/last_seen"/>
<TextView
android:id="#+id/switch_status"
android:layout_below="#id/switch_lastSeen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/switch_row_level"
android:text="#string/status"/>
<ImageButton
android:id="#+id/switch_button_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_up"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
<ImageButton
android:id="#+id/switch_button_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_stop"
android:layout_toLeftOf="#+id/switch_button_down"
android:layout_toStartOf="#+id/switch_button_down"
android:layout_centerVertical="true" />
<ImageButton
android:id="#+id/switch_button_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_down"
android:layout_toLeftOf="#+id/switch_button_up"
android:layout_toStartOf="#+id/switch_button_up"
android:layout_centerVertical="true" />
</RelativeLayout>
How the row looks on my phone (the same on a API 19 AVD):
How Android Studio, when designing, shows the row:
try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp">
<TextView
android:id="#+id/switch_name"
style="#style/switch_row_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Switch name" />
<TextView
android:id="#+id/switch_lastSeen"
style="#style/switch_row_lastSeen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/switch_name"
android:text="#string/last_seen" />
<TextView
android:id="#+id/switch_status"
style="#style/switch_row_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/switch_lastSeen"
android:text="#string/status" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:orientation="horizontal">
<ImageButton
android:id="#+id/switch_button_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_up" />
<ImageButton
android:id="#+id/switch_button_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_stop" />
<ImageButton
android:id="#+id/switch_button_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_down" />
</LinearLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="90dip"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<TextView
android:id="#+id/rowcontact_txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:text="Usama Sadiq"
android:textColor="#3a3838"
android:textSize="15dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/rowcontact_imgLocationIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_below="#+id/rowcontact_txtName"
android:layout_marginLeft="10dip" />
<TextView
android:id="#+id/rowcontact_txtLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rowcontact_txtName"
android:layout_toRightOf="#+id/rowcontact_imgLocationIcon"
android:text="Dubai"
android:textColor="#898788"
android:textSize="11.5dp" />
<ImageView
android:id="#+id/rowcontact_imgIcon"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignBottom="#+id/rowcontact_txtLocation"
android:layout_marginLeft="94dp"
android:layout_toRightOf="#+id/rowcontact_txtName" />
</RelativeLayout>
</RelativeLayout>
i am trying to create layout for list-view item but i am not able to fix position of image and text with three different Position please tell me solution how to fix it. i have to create listviow item i am able to display list-view but like given screen
i have all icon an all but am unable to fix potion of text-view and image view like given screen
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="2"
android:layout_margin="5dp"
>
<TextView
android:id="#+id/rowcontact_txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Usama Sadiq"
android:textColor="#3a3838"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="#+id/rowcontact_txtLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rowcontact_txtName"
android:layout_toRightOf="#+id/rowcontact_imgLocationIcon"
android:text="Dubai"
android:textColor="#898788"
android:textSize="11.5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
I am trying to create a certain layout, that consists of 2 parts a scrollview and a "footer" at the bottom, but always on top of the scrollview. Everything inside the scrollview must be visible (by scrolling).
This is my current code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/banner" />
<TextView
android:layout_width="fill_parent"
android:paddingTop="1dp"
android:layout_height="3px"
android:background="#DADADA" />
<RelativeLayout
android:id="#+id/InnerRelativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Start Connecting" />
<Button
android:id="#+id/button01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/button1"
android:layout_alignParentLeft="true"
android:text="First use" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="Welcome to ADB Wireless!"
android:textSize="25sp" />
</RelativeLayout>
</LinearLayout>
But it gives an overlap on small screens & landscape mode. I would only like to have the 2 buttons to be inside the 'footer'. Thank you!
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/button_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Next" />
<Button
android:id="#+id/button01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Previous" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/button_layout" >
</ScrollView>
</RelativeLayout>
I have to create the following layout on an Android device:
The requirements are as follows:
First layout which occupies the whole screen (fill_parent);
Second (at the bottom of the screen) overlays the first one and has the following formats:
3 columns;
occupies the whole screen width;
arrows are aligned left and right sides, and text area is resized based on screen width;
I've tried numerous things, but since I'm new to the Android world, I had no success yet.
Here is what I have so far:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="100"
android:id="#+id/RootView">
<ImageView
android:src="#android:drawable/ic_menu_gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:id="#+id/mapImageView" />
<LinearLayout
android:id="#+id/bottomArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<LinearLayout
android:id="#+id/adsArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<ImageButton
android:src="#drawable/leftArrow"
android:id="#+id/btnPrev"
android:layout_alignParentRight="true"
android:layout_marginLeft="0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is some summary text" />
</LinearLayout>
<ImageButton
android:src="#drawable/rightArrow"
android:layout_alignParentRight="true"
android:layout_marginRight="0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btnNext" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
but the text doesn't seem to be center aligned, nor resized to the screen width:
Does someone has a clue?
Thanks.
Use this code for your required layout...
<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=".MainActivity" >
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/linear2" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<RelativeLayout
android:id="#+id/linear2"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<ImageButton
android:id="#+id/leftButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/rightButton1"
android:layout_toRightOf="#+id/leftButton1"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is some summary text" />
</LinearLayout>
<ImageButton
android:id="#+id/rightButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
Please find the code below. Also, do not use multiple viewgroup for simple layout solution.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RootView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/mapImageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#android:drawable/ic_menu_gallery" />
<RelativeLayout
android:id="#+id/adsArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<ImageButton
android:id="#+id/btnPrev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="#drawable/leftArrow" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is some summary text" />
</LinearLayout>
<ImageButton
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/rightArrow" />
</RelativeLayout>
</RelativeLayout>
I'd like to center these phrases in my view. I can get "#+id/m_popcorn" to the center of the screen but, I cannot get"#+id/m_keyhole" and the other text views to line up beneath it. I would also like all five phrases to be centered in the screen, rather than having only "#+id/m_popcorn" centered. What am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center" >
<ImageView
android:id="#+id/viola_desmond_pic"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:contentDescription="#string/desc"
android:src="#drawable/viola_desmond" />
<TextView
android:id="#+id/list_background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#AA000000"
android:contentDescription="#string/desc" >
</TextView>
<TextView
android:id="#+id/m_popcorn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="spilled popcorn" />
<TextView
android:id="#+id/m_keyhole"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/m_popcorn"
android:layout_centerHorizontal="true"
android:text="keyhole" />
<TextView
android:id="#+id/m_pistol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/m_keyhole"
android:layout_centerHorizontal="true"
android:text="pistol" />
<TextView
android:id="#+id/m_cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/m_pistol"
android:layout_centerHorizontal="true"
android:text="cat" />
<TextView
android:id="#+id/m_pen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/m_cat"
android:layout_centerHorizontal="true"
android:text="pen" />
</RelativeLayout>
Here is the layout file...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/viola_desmond_pic"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:contentDescription="testing"
android:src="#drawable/icon" />
<LinearLayout
android:id="#+id/ll_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/list_background"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#AA000000"
android:contentDescription="text description"
android:gravity="center_horizontal" >
</TextView>
<TextView
android:id="#+id/m_popcorn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="spilled popcorn" />
<TextView
android:id="#+id/m_keyhole"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="keyhole" />
<TextView
android:id="#+id/m_pistol"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="pistol" />
<TextView
android:id="#+id/m_cat"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="cat" />
<TextView
android:id="#+id/m_pen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="pen" />
</LinearLayout>
</RelativeLayout>
you can use this code to have a list of textView in center of your layout, i am using a linear layout that fill the parent layout and set it's gravity to center, any child of this layout is in the center of it :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:scaleType="center">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:gravity="center"
android:id="#+id/linearLayout1">
<TextView
android:contentDescription="desk"
android:text="TextView"
android:id="#+id/list_background"
android:layout_height="wrap_content"
android:background="#AA000000"
android:layout_width="wrap_content"></TextView>
<TextView
android:id="#+id/m_popcorn"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="spilled popcorn"></TextView>
<TextView
android:id="#+id/m_keyhole"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="keyhole"></TextView>
<TextView
android:id="#+id/m_pistol"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="pistol"></TextView>
<TextView
android:id="#+id/m_cat"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="cat"></TextView>
<TextView
android:id="#+id/m_pen"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="pen"></TextView>
</LinearLayout>
<ImageView
android:contentDescription="desk"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/viola_desmond_pic"
android:src="#drawable/icon"
android:layout_alignParentRight="true"></ImageView>
</RelativeLayout>