Pyae Phyoe Shein
Pyae Phyoe Shein

Reputation: 13827

Android textview over imageview with background transparent

Please let me know how to add textview over imageview with background transparent as per image. Detail is I want to add two textview over imageview, one textview is title and the rest one is description. And background is transparent. Please help.enter image description here

Upvotes: 4

Views: 10413

Answers (4)

Milon
Milon

Reputation: 2249

one possible way: add Framelayout as root and then add textview and imageview like this

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ImageView  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 

    android:scaleType="center"
    android:src="@drawable/golden_gate" />

<TextView
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="20dip"
    android:layout_gravity="center_horizontal|bottom"

    android:padding="12dip"

    android:background="#AA000000"
    android:textColor="#ffffffff"

    android:text="Golden Gate" />

 </FrameLayout>

Upvotes: 3

Kiumars
Kiumars

Reputation: 46

You can use a FrameLayout as container and to overlay TextView on the ImageView and assign a background of lower alpha channel #AARRGGBB

Upvotes: 1

Wajdi Hh
Wajdi Hh

Reputation: 785

You set the image as a background of your layout parent, for example RelativeLayout, and then you put and other layout with background transparent in the bottom of the first layout. Then we put your textView inside the second layout.

Upvotes: 0

rdbmsa
rdbmsa

Reputation: 306

I think you should use merge tag in xml of your layout.. For example Merge example

Upvotes: 8

Related Questions