Reputation: 139
I want to put the text below image like picture below:
the layout coding now :
<?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="wrap_content"
android:background="@drawable/list_selector"
android:orientation="horizontal"
android:padding="0dip" >
<LinearLayout android:id="@+id/thumbnail"
android:layout_width="fill_parent"
<--some coding here -->
android:layout_marginRight="0dip">
<ImageView
android:id="@+id/list_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:src="@drawable/test"/>
</LinearLayout>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="clip_horizontal"
android:layout_centerInParent="true"
android:text="test"
android:textColor="#FFFFFF"
android:typeface="sans"
android:textSize="15dip"
android:textStyle="bold"/>
</RelativeLayout>
anyone know how to make it like the photo because rite now, the text in the center of the image.
thank you,.
Upvotes: 0
Views: 1691
Reputation: 412
I think this stuff really helps you..
Instead of an ImageView and Textview ,have an option to set image and text inside
<Button android:id="@+id/textwithImage" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableTop="@drawable/test" android:text="test" android:textColor="#FFFFFF" android:typeface="sans" android:textSize="15dip" android:textStyle="bold" android:gravity="center" android:padding="15dp" />
Upvotes: 0
Reputation: 28484
Try this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="0dip" >
<LinearLayout
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/list_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="test"
android:textSize="15dip"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
Upvotes: 0
Reputation: 3373
Replace android:layout_centerInParent="true"
by android:layout_below="@id/thumbnail"
+ android:layout_centerHorizontal="true"
<?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="wrap_content"
android:background="@drawable/list_selector"
android:orientation="horizontal"
android:padding="0dip" >
<LinearLayout android:id="@+id/thumbnail"
android:layout_width="fill_parent"
<--some coding here --> android:layout_marginRight="0dip">
<ImageView
android:id="@+id/list_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:src="@drawable/test"/>
</LinearLayout>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="clip_horizontal"
android:layout_below="@id/thumbnail"
android:layout_centerHorizontal="true"
android:text="test"
android:textColor="#FFFFFF"
android:typeface="sans"
android:textSize="15dip"
android:textStyle="bold"/>
</RelativeLayout>
Upvotes: 1