Subha
Subha

Reputation: 761

How to create the layout like android contacts favorite

How to create the Layout like the (Android ICS Contacts Favorite layout )image i attached

Layout with image and overlay name

am using the grid view for creating the layout for the photos grid. Thats perfectly working. But

how can i create the overlay layout like the black transparent with name or image ?? any one guide me to do this

Thanks in advance

Upvotes: 2

Views: 1140

Answers (1)

Siddharth Lele
Siddharth Lele

Reputation: 27748

Try this: (Note: this is the Custom XML Layout for the GridView that will be setup in the Adapter)

<FrameLayout
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:gravity="center" >

    <ImageView
        android:id="@+id/imgProfilePicture"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:src="@drawable/ic_contact_picture" >
    </ImageView>

    <TextView
        android:id="@+id/txtUserName"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center"
        android:background="#50000000"
        android:gravity="center"
        android:text="User Name"
        android:textColor="#ffffff"
        android:textSize="11sp" >
    </TextView>
</FrameLayout>

And it will look this:

enter image description here

This is as-is from one of my apps. Play around with the android:layout_width and the android:layout_height to set your own size. Also, fiddle with this android:background="#50000000" attribute to get it looking as you please. The 50 in it is the alpha that will set the transparency.

Upvotes: 2

Related Questions