I'm confused why android:layout_below is not working, I just need to put the button below the border line and I don't wanna use android:layout_marginTop="570dp because the android phone has different sizes, Is somebody know how can I arrange the layout of this? it helps me a lot thanks in advance.
This is what I want to achieve
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="100dp"
android:background="#drawable/selector_fieldset_background"
android:orientation="vertical"
android:id="#+id/linearl">
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#color/white"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="Cash Card Scanner"
android:textSize="15dp"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<Button
android:id="#+id/button2"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SCAN"
android:layout_below="#+id/linearl"
/>
</RelativeLayout>
Drawable selector_fieldset_background.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FFFFFF" />
<stroke
android:width="2dip"
android:color="#25000000" />
</shape>
Just try this, works for me:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/selector_fieldset_background"
android:orientation="vertical"
android:id="#+id/linearl"
android:layout_above="#+id/button2"
>
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#color/white"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="Cash Card Scanner"
android:textSize="15dp"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<Button
android:id="#+id/button2"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="90dp"
android:text="SCAN"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Related
I saw some same questions, but
I'm using android:orientation="vertical"
so I can't use orientation as horizontal.
How can I display 2 or more textviews on 1 row?
(Sorry for my english skills)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:background="#drawable/background"
android:weightSum="1">
<TextView
android:layout_width="62dp"
android:layout_height="28dp"
android:layout_gravity="right"
android:text="Sign in"
android:textColor="#7041EE"
android:textSize="20dp" />
<TextView
android:id="#+id/nwah"
android:layout_width="162dp"
android:layout_height="28dp"
android:layout_gravity="left"
android:text="New around here?"
android:textColor="#ACACAC"
android:textSize="20dp" />
</LinearLayout>
enter image description here
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:background="#drawable/background"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="0dp"
android:layout_height="28dp"
android:layout_gravity="right"
android:layout_weight="1"
android:text="Sign in"
android:textColor="#7041EE"
android:textSize="20dp" />
<TextView
android:id="#+id/nwah"
android:layout_width="0dp"
android:layout_height="28dp"
android:layout_weight="1"
android:layout_gravity="left"
android:text="New around here?"
android:textColor="#ACACAC"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
You can add another view for textView
<LinearLayout // vertical
<LinearLayout // hotizontal
<TextView/>
<TextView/>
<LinearLayout/>
<LinearLayout/>
or you can use Constraint layout
Well I have achieved the rounded corner goal in alert dialog box but it has taken all the left and right side.
My question is like I want some space between left and right of the dialog box
Here is my code:Custom dialog
<?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="wrap_content"
android:orientation="vertical"
android:background="#drawable/custom_dialog"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="SELECT PHOTO"
android:textSize="15dp"
android:paddingBottom="12dp"
android:paddingTop="12dp"
android:layout_marginLeft="20dp"></TextView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/hint_color"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="15dp"
android:id="#+id/Select_photo_from_Camera">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/camera_24dp"
android:layout_marginLeft="22dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Camera"
android:layout_marginLeft="10dp"
></TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="600dp"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="#color/hint_color"></View>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="15dp"
android:paddingBottom="5dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_photo_library_black_24dp"
android:layout_marginLeft="22dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gallery"
android:layout_marginLeft="10dp"
/>
</LinearLayout>
</LinearLayout>
Code for :Custom_dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="#color/white"></solid>
<corners
android:radius="5dp"
></corners>
<padding
android:top="6dp"
android:bottom="6dp"></padding>
</shape>
Here is the Output of my achievement:
https://i.stack.imgur.com/7G0Go.png
Create a inset and set as background, that may help
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="#drawable/your_background_image"
android:insetRight="25dip"
android:insetLeft="25dip" />
use
android:background="#drawable/inset_background"
I have this recyclerview, and the background is made with imageviews. I have these two situations in portrait and landscape. How do I fill the white space there with a new imageview or something with the same color?
And this is my xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/home_imageview_superbackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true" />
<ImageView
android:id="#+id/home_imageview_background"
android:contentDescription="Background image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_alignParentEnd="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true">
<TextView
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="casual"
android:paddingBottom="10dp"
android:paddingStart="5dp"
android:paddingTop="10dp"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="#android:color/white"
android:textSize="40sp" />
</RelativeLayout>
Tried several ways, but I'm just not able to make this work. #+id/home_imageview_superbackground this is the imageview I want to put on the left of each background imageview to fill that space in the landscape. Thank you for the help.
Please try this one
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/home_imageview_superbackground"
android:layout_width="match_parent"
android:src="#mipmap/ic_launcher"
android:scaleType="fitXY"
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/home_imageview_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher"
android:scaleType="fitXY"
android:contentDescription="Background image" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true">
<TextView
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="casual"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="#android:color/white"
android:textSize="40sp" />
</RelativeLayout>
</RelativeLayout>
You can also use android:scaleType="centerCrop".
Hope this will help you..If still you face problem please inform me...
<ImageView
android:layout_width="match_parent"
.... />
Also you can use scaleTypeattribute
First, the fill_parent is deprecated times ago, you should use match_parent instead. Then, you have also to use scaleType when you're working with ImagesView to define how the image looks on the screen. In your case, working with scaleType = "fitXY" solve your problem.
How your code should be :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/home_imageview_superbackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:layout_alignParentStart="true" />
<ImageView
android:id="#+id/home_imageview_background"
android:contentDescription="Background image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:layout_alignParentEnd="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true">
<TextView
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="casual"
android:paddingBottom="10dp"
android:paddingStart="5dp"
android:paddingTop="10dp"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="#android:color/white"
android:textSize="40sp" />
</RelativeLayout>
Try this code
<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/your_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher"
android:scaleType="fitEnd"
android:layout_alignParentStart="true"
android:background="#drawable/green_gradiant"
android:padding="10dp" />
<TextView
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="casual"
android:paddingBottom="10dp"
android:paddingStart="5dp"
android:paddingTop="10dp"
android:text="Hello Three"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="#android:color/white"
android:textSize="40sp" />
</FrameLayout>
And create this drawable file
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient android:angle="0"
android:startColor="#64FFDA"
android:centerColor="#4464FFDA"
android:endColor="#0064FFDA"/>
</shape>
</item>
</selector>
I want to do this :
I did 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:id="#+id/activity_aplication_settings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e2e2e2"
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="com.smok.maps.AplicationSettings">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<TextView
android:id="#+id/textSync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="#string/sync" />
<LinearLayout
android:id="#+id/line1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textSync">
<TextView
android:id="#+id/actual"
android:layout_width="wrap_content"
android:textColor="#000000"
android:layout_height="wrap_content"
android:text="#string/actual" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/count" />
<TextView
android:id="#+id/actual2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="min" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/line1"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox1"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="#xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/point" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#000000"
android:text="#string/show_choose_point" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lin2"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="#xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/sync" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:gravity="center"
android:text="#string/sync_request" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lin3"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="#xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/show_chooce" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:gravity="center"
android:text="#string/show_choosen_points" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lin4"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox4"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="#xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/position2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#000000"
android:text="#string/current_location" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:orientation="horizontal">
<Button
android:id="#+id/back_bt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#ffffff"
android:background="#xml/roundedbutton"
android:text="#string/back" />
<View
android:layout_width="0dp"
android:layout_weight="0.1"
android:layout_height="match_parent">
</View>
<Button
android:id="#+id/confirm_bt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#ffffff"
android:background="#xml/roundedbutton"
android:text="#string/save" />
</LinearLayout>
</RelativeLayout>
I don't have idea how I can do border. I want to do a border and in the middle I want to have place to put text.This same how is in the screen. This look like a frame which have a text. Now I have onli text and I don not how I can create a frame.
Here is demo of your requirement.
1) You need to create a border.xml. Put this in your drawable folder. Add the following code in border.xml :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!--stroke width and color-->
<stroke
android:width="2dp"
android:color="#android:color/darker_gray" />
<!-- corner radius-->
<corners
android:radius="5dp" />
<!--paddings-->
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
</shape>
2) Here is the layout.xml put the background to a linearlayout accordingly:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="bd.com.tahsin.myapplicationnavgroup.MainActivity"
tools:showIn="#layout/app_bar_main">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:layout_marginTop="5dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:background="#drawable/bottom_border_help">
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MENU_BOCZNE"
android:background="#color/background_floating_material_light"
android:layout_marginLeft="10dp" />
</RelativeLayout>
3) And finally the screen-shot:
Hope, this will help a bit.
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="match_parent"
android:layout_margin="15dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/border"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="TEST"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text=" MENU "
android:layout_marginLeft="15dp"
android:background="#ffffff"
android:textSize="17sp" />
</RelativeLayout>
xml of border.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="3dp"/>
<stroke
android:width="2dp"
android:color="#cdcdcd" />
</shape>
I am using this layout for my screen:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" android:background="#drawable/tmp" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/uph"
android:layout_gravity="top|center" android:layout_marginTop="-10dp"/>
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/propfile"
android:layout_gravity="top|center"/>
</LinearLayout>
and i want to add a TextView to the screen that will be above the imageView2.
and when i add it to the xml it show it under the image.
what i need to do to be able to put TextView on image.
Try this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" android:background="#drawable/tmp" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/uph"
android:layout_marginTop="-10dp"/>
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center">
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/propfile"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</LinearLayout>
You could add another LinearLayout where the second image is, for example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" android:background="#drawable/tmp" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/uph"
android:layout_gravity="top|center" android:layout_marginTop="-10dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text Goes Here" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/propfile"
android:layout_gravity="top|center"/>
</LinearLayout>
</LinearLayout>
Here is an alternative,
in your xml file,
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text"
android:layout_centerInParent="true"
android:layout_above="idofyourImage"
/>
Hope it helps