Reputation: 499
I want to place a single TextView
over five ImageViews
.the ImageViews
are placed in a single TableRow
.Is there any option available for that.Please help me..
Thanks in advance.
Upvotes: 2
Views: 399
Reputation:
Try these one:
<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"
>
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="84dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow_icon_normal"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow_icon_pressed"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/audio_normal"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/audio_pressed"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/back_normal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
/>
</TableRow>
</TableLayout>
</RelativeLayout>
Upvotes: 2
Reputation: 4108
The above answer are correct. If you need it in table layout try this one.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableLayout
android:id="@+id/tb1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/image3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</TableRow>
</TableLayout>
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/tb1"
android:layout_alignParentLeft="true"
android:layout_marginBottom="2dp"
android:text="i am text on image views"
android:textColor="#ff0000" />
</RelativeLayout>
</RelativeLayout>
Upvotes: 1
Reputation: 1811
What about using your TableLayout as "outer" layout and for each table cell you use a FrameLayout as "inner" layout. Using this FrameLayout, both ImageView and TextView will overlap.
Upvotes: 1
Reputation: 1495
Set main layout as Relative Layout
inside that add your Table Layout
then from the graphical layout add TextView
wherever you need.
Upvotes: 1
Reputation: 18923
Use this one.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="bottom"
android:src="@drawable/image" />
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/image1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="2dp"
android:text="@string/text"
android:textColor="#ff0000" />
</RelativeLayout>
</RelativeLayout>
Upvotes: 4
Reputation: 1967
Use Relative layout firstly create a table layout for height and width set as wrap contents align gravity center similarly then add a textView also with gravity center this way textview will come over the table layout.
Upvotes: 2
Reputation: 4857
Try insert this code:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="bottom"
android:src="@drawable/image" />
<TextView
android:id="@+id/text1"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/image1"
android:layout_alignBottom="@id/image1"
android:layout_alignLeft="@id/image1"
android:layout_alignRight="@id/image1"
android:layout_alignTop="@id/image1"
android:text="@string/text" />
</RelativeLayout>
Upvotes: 1