user139934
user139934

Reputation: 33

Floating list view items

I am looking to do something like this:

enter image description here

I am thinking it is a ListView, with a shaded background, and the listViews items have margins spacing them apart from eachother and the edges of the screen.

Am I on the right track? or is there a better way to do this.

Upvotes: 2

Views: 3048

Answers (2)

matiash
matiash

Reputation: 55350

Those are usually known as Cards in Android. They're basically just layouts with a drop shadow, but there are some libraries to ease implementation, such as Gabriele Marotti's CardsLib.

Also, the new "L" Developer Preview for Android includes this widget as a first-class citizen (CardView), since it's quite prominent in the recently unveiled "Material Design". It's also available as part of the Support Library for older versions of Android.

Upvotes: 1

Hareshkumar Chhelana
Hareshkumar Chhelana

Reputation: 24848

Try this way,hope this will help you to solve your problem.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/button_default"> // here set your shaded background

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center_vertical"
        android:padding="10dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello stackoverflow"/>

        </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center"
        android:padding="10dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="22sp"
            android:text="25"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:textSize="22sp"
            android:text="Wrd"/>
    </LinearLayout>

</LinearLayout>

Upvotes: 0

Related Questions