Reputation: 9804
I have a layout with an imageview and a textview.
I would like to have something like this :
An imageview with a title but i would like that the layout of the title be transparent in order to show the imageview in background.
Here is the code of my layout :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_marginBottom="3dp" >
<ImageView
android:id="@+id/imgimg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/ic_action_picture"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/titlenew"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="TextView"
android:textColor="@color/blanc" />
</RelativeLayout>
</LinearLayout>
Upvotes: 1
Views: 2654
Reputation: 6738
try this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_marginBottom="3dp" >
<ImageView
android:id="@+id/imgimg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/titlenew"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#80000000"
android:gravity="center"
android:padding="5dp"
android:text="TextView"
android:textColor="#fff" />
</RelativeLayout>
Upvotes: 4
Reputation: 1264
Here you go :)
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/imgimg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_action_picture"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/titlenew"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="bottom"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_gravity="bottom"
android:background="#99000000"
android:textColor="@color/blanc" />
</FrameLayout>
Upvotes: 0
Reputation: 8488
You can add this to textview:
android:background="#00000000"
If you want to control transparency of backgrounf play with alpha value like this:
android:background="#CCFF0000"
Upvotes: 0
Reputation: 2326
Try to set android:background="@android:color/transparent"
on TextView
.
Upvotes: 1