Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text overlay over imageview in android

I am trying to have textviews overlay over imageviews. Something like this

people app

Can someone help me with the code.

like image 406
Vinay Gaba Avatar asked Nov 09 '13 14:11

Vinay Gaba


1 Answers

You can create a frame layout and within the frame layout keep an imageview and a linearlayout(with a translucent background and a textview).

The translucent color can be placed in the colors file as : #80000000 Here is a snippet :)

 <FrameLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/mainlayout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:foregroundGravity="bottom"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/ivFullScreenAd"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_marginBottom="8dp"
                android:src="@drawable/home_page_ad" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:background="@color/translucent"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/detailTitle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="left"
                    android:paddingLeft="10dip"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="Please swipe up"
                    android:textColor="@color/white"
                    android:textIsSelectable="true"
                    android:textSize="20sp" />
            </LinearLayout>
        </FrameLayout>
like image 147
Bijay Koirala Avatar answered Sep 21 '22 03:09

Bijay Koirala