Iam having a custom list view where in a row i have 3 text views and 3 images each below each textview
(Relative Layout)
TextView1 Textiew2 TextView3
opening---->(LinearLayout1) (LinearLayout2) (LinearLayout3)
ImageView1 ImageView2 ImageView3
closing---->(/LinearLayout1) (/LinearLayout2) (/LinearLayout3)
closing-->(/RelativeLayout)
Now the output comes like the imageview is not center totextview, i mean if you have your text and image in center and its centerhorizontal then how it looks like, i need same on right and left end too, text and image in right end should be centered in right side , and same for left also. Please suggest me what to do.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="49dp"
android:layout_marginTop="43dp"
android:gravity="center"
android:text="TextView" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_below="#+id/textView1"
android:layout_marginRight="47dp" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/book1" />
</LinearLayout>
</RelativeLayout>
In this above xml my textview is leftaligned and its text inside is centered, Now iam having one image below it which i want to align center of the above textview not parents center
Try this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.33">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your title"
android:textStyle="bold" />
<ImageView
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.33">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your title"
android:textStyle="bold" />
<ImageView
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.34">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your title"
android:textStyle="bold" />
<ImageView
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
Try That:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="49dp"
android:layout_marginTop="43dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TextView" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/book1" />
</LinearLayout>
Related
I want to place one textView at the left and 2 TextView at the Right.
Right now the 2 textview at the right are placed ontop of one another.
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<TextView
android:id="#+id/mytextview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:layout_alignParentLeft="true" />
<TextView
android:id="#+id/mytextview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="FOLLOWING"
android:layout_toRightOf="#id/mytextview1"
android:gravity="right"/>
<TextView
android:id="#+id/mytextview3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="EXPLORE"
android:layout_toRightOf="#id/mytextview1"
android:gravity="right"/>
</RelativeLayout>
How do I place "mytextview2" and "mytextview3" at the right with space.
Try to set mytextview3 at the right using android:layout_alignParentRight and then mytextview2 left of mytextview3 using android:layout_toLeftOf
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<TextView
android:id="#+id/mytextview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:layout_alignParentLeft="true" />
<TextView
android:id="#+id/mytextview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FOLLOWING"
android:layout_toLeftOf="#id/mytextview3"/>
<TextView
android:id="#+id/mytextview3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EXPLORE"
android:layout_marginLeft="5dp"
android:layout_alignParentRight="true"/>
</RelativeLayout>
Try it like this :
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<TextView
android:id="#+id/mytextview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="TextView1" />
<TextView
android:id="#+id/mytextview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/mytextview3"
android:layout_marginRight="5dp"
android:text="FOLLOWING" />
<TextView
android:id="#+id/mytextview3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="EXPLORE" />
</RelativeLayout>
Use below to set view position using android:layout_toRightOf. Set mytextview3 to right of mytextview2 instead of mytextview1 and also set the width both of the view as wrap_content
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<TextView
android:id="#+id/mytextview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:layout_alignParentLeft="true" />
<TextView
android:id="#+id/mytextview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FOLLOWING"
android:layout_toRightOf="#id/mytextview1"
android:gravity="right"/>
<TextView
android:id="#+id/mytextview3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EXPLORE"
android:layout_toRightOf="#id/mytextview2"
android:gravity="right"/>
</RelativeLayout>
I need to take a textview within Tablelayout with a image icon left to TextView. The TableLayout have width has fill_parent, so that whole area is clickable.
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="top"
android:drawablePadding="5dp"
android:drawableStart="#drawable/down_arrow"
android:gravity="start|center"
android:text="#string/hello_world" />
</TableLayout>
I tried to bring the Textview with image to center, but not able to do that.
Kindly help me to achieve the same.
Thanks
Vikash
try this :
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:drawablePadding="5dp"
android:drawableStart="#drawable/ic_launcher_0"
android:gravity="start|center"
android:text="#string/hello_world" />
</TableRow>
</TableLayout>
Use this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:src="#drawable/app_icon" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_marginBottom="24dp"
android:layout_marginLeft="20dp"
android:layout_toRightOf="#+id/imageView1"
android:text="TextView" />
</RelativeLayout>
I'm building an android app and I am trying to set my layout without any success.
I searched everywhere and I can't seem to find any solution.
I need to place 2 text views on top of an image.
the first text view need to be about 10dp above the vertical center of the image.
and the second text view should be below text view 1.
here's my code so far, though it doesn't work.
can anyone here tell me what I'm missing or what am I doing wrong?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
android:orientation="vertical"
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.boromedia.parve.MainActivity" >
<RelativeLayout
android:id="#+id/blueOvalLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginBottom="20dp"
android:layout_marginTop="75sp" >
<ImageView
android:id="#+id/blueOval"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:src="#drawable/blueoval" />
<ImageView
android:id="#+id/greenOval"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:src="#drawable/greenoval_small"
android:visibility="gone" />
<TextView
android:id="#+id/greenOvalText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="65dp"
android:gravity="center|center_vertical"
android:text="#string/counter_activity_oval_done"
android:textColor="#fff"
android:textSize="28sp"
android:visibility="gone" />
<TextView
android:id="#+id/blueOvalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="#string/counter_activity_oval_text1"
android:textColor="#fff"
android:textSize="18sp" />
<TextView
android:id="#+id/blueOvalTimer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/blueOvalText"
android:layout_centerHorizontal="true"
android:text="#string/counter_default"
android:textColor="#fff"
android:textSize="25sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
<TextView
android:id="#+id/head_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="15dp"
android:gravity="center_vertical|center"
android:text="#string/main_title"
android:textSize="30sp" />
<Button
android:id="#+id/stopButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#android:color/transparent"
android:text="#string/counter_activity_stop_button"
android:textSize="20sp" />
Try this workaround: Change your textView for:
<RelativeLayout
android:id="#+id/wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginBottom="10dp" >
<TextView
android:id="#+id/blueOvalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/counter_activity_oval_text1"
android:textColor="#fff"
android:textSize="18sp" />
</RelativeLayout>
This is a wrapper for setting the margin of 10dp.
Don't forget that your second textview should be below the wrapper, not below the textview!
I hope this would help;)
You can put your 2 TextView in a LinearLayout which will be centered in the parent :
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true" >
<TextView
android:id="#+id/blueOvalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="#string/counter_activity_oval_text1"
android:textColor="#fff"
android:textSize="18sp" />
<TextView
android:id="#+id/blueOvalTimer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/blueOvalText"
android:layout_centerHorizontal="true"
android:text="#string/counter_default"
android:textColor="#fff"
android:textSize="25sp" />
</LinearLayout>
I have comman header with two button and single textview.
textview is in center of the screen. button 1 is at the right side of the parent and button2 is at the left side of the parent.
now, I want to show text view in the center of the parent not in the center of the space between two buttons.
Text length in the textview can be any thing either it could be 3 words or it could be more than 10 word.
I dont want to overlap textview above the two buttons while length is more than 10 words.
and also I want textview in the center of the screen while there is only 3 words.
When I am using below code it is not showing textview in the center of the screen horizontally when there is only 3 to 4 words but below code also dont overlap while there is more than 10 words.
<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=".Webviewdemo" >
<ImageView
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/backbtn" />
<ImageView
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/infobtn" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_toLeftOf="#+id/button2"
android:layout_toRightOf="#+id/button1"
android:gravity="center"
android:singleLine="true"
android:text="123"
android:textSize="22sp"/>
</RelativeLayout>
In same way When I am using below code it is showing textview in the center of the screen horizontally when there is only 3 to 4 words but below code overlap while there is more than 10 words.
<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=".Webviewdemo" >
<ImageView
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/backbtn" />
<ImageView
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/infobtn" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:singleLine="true"
android:text="123"
android:textSize="22sp" />
</RelativeLayout>
So, My question is how can I achive above both thing with single code.
Textview should not overlap while there is more words.
Textview should be in center while there is less no of words.
I hope you all get my problem. if any query plz ask.
<LinearLayout
android:id="#+id/panelIconLeft1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="5dp" >
<Button
android:id="#+id/btnHome1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LOCATION"
android:onClick="btnHomeClick" />
</LinearLayout>
<TextView
android:id="#+id/txtHeading1"
style="#style/heading_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/panelIconRight1"
android:layout_toRightOf="#id/panelIconLeft1"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:singleLine="true"
android:text=""
android:textColor="#android:color/white" />
<LinearLayout
android:id="#+id/panelIconRight1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="5dp" >
<Button
android:id="#+id/btnFeedback1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Post Ad"
android:onClick="btnFeedbackClick" />
</LinearLayout
The above code will help you
Use This Code
<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="match_parent"
android:layout_weight="1"
android:gravity="left">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="right" >
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
try this code
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/button2"
android:layout_toRightOf="#+id/button1"
android:gravity="center"
android:singleLine="true"
android:text="123"
android:textSize="22sp"/>
EDIT
remove this line
android:layout_centerInParent="true"
try this (without centerInParent)
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/button2"
android:layout_toRightOf="#+id/button1"
android:gravity="center"
android:singleLine="true"
android:text="123"
android:textSize="22sp"/>
I want to center align my imageview with the above textview here's an image of what I'm getting.
I need something like this in a relative layout
<TextView
android:id="#+id/strength"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/hero_class"
android:textColor="#0095FF"
android:text="Strength"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/agility"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/hero_class"
android:layout_centerHorizontal="true"
android:text="Agility"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#0095FF" />
<TextView
android:id="#+id/intl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/agility"
android:layout_alignBottom="#+id/agility"
android:layout_alignParentRight="true"
android:text="Intelligence"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#0095FF" />
<ImageView
android:id="#+id/img_int"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/img_str"
android:src="#drawable/intelligence" />
<ImageView
android:id="#+id/img_agi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/img_int"
android:layout_centerHorizontal="true"
android:src="#drawable/agility" />
<ImageView
android:id="#+id/img_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/strength"
android:layout_alignParentLeft="true"
android:src="#drawable/strength" />
This is what i have done but the problem is that i can have the middle imageview centered align but the left and right one are with align to the most right and most left not in the center of above textview
In layout.xml you can use this for each Text+Image:
<TextView ...
android:text="The Text"
android:drawableBottom="#drawable/icon1" />
You could repeat it into an LinearLayout with the horizontal orientation
You can make three Relative Views each containing a Textview and Imageview posited one below the other with the ImageView in the cater of the parent Relative View.
Finally put these three within an outer Relative View to position them as you like.
Try to create three linear layouts with orietation vertical,
Each linear layout will contain textview and imageview with gravity center
You can use LinearLayout as parent Layout having android:orientation="horizontal".
and then use three LinearLayout each contains TextView and ImageView having android:orientation="vertical".
See below code-
<?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="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/strength"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/hero_class"
android:textColor="#0095FF"
android:text="Strength"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="#+id/img_agi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/img_int"
android:layout_centerHorizontal="true"
android:src="#drawable/agility" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
TextView ImageView
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
TextView ImageView
</LinearLayout>
</LinearLayout>
Hope this helps:
<?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:background="#android:color/black" >
<RelativeLayout
android:id="#+id/reltive1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" >
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="TEXT VIEW"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/img1"
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_below="#id/text1"
android:layout_centerHorizontal="true"
android:background="#android:color/white" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/reltive1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="TEXT VIEW"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/img2"
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_below="#id/text2"
android:layout_centerHorizontal="true"
android:background="#android:color/white" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/reltive1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="TEXT VIEW"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/img3"
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_below="#id/text3"
android:layout_centerHorizontal="true"
android:background="#android:color/white" />
</RelativeLayout>
</RelativeLayout>
This is what you want...
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="TextView" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/imgView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/imgView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
</LinearLayout>
Check if your ImageView is centered on your layout with this attribute:
android:layout_centerHorizontal="true"
For your TextView, it needs a reference to be aligned above it and also be centered.
So you need this:
android:layout_alignParentEnd="#+id/imageView"
android:layout_alignParentRight="#+id/imageView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="center"
Create GridView adapter and your done.