Home

Monday 22 June 2015

Using CardView - Material design

Using CardView - Material design : 

First of all to use CardView add this in your gradle file(app) within dependencies add :

dependencies {
    ...
    compile 'com.android.support:cardview-v7:22.0.+'

}


To use CardView add this in your layout(xml) file :

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/cardview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_weight="1"
        android:clickable="true"
        android:foreground="?android:attr/selectableItemBackground"
        card_view:cardBackgroundColor="#ffff4966">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_margin="10dp"
            android:text="This is a Card View"
            android:textSize="25dp" />

    </android.support.v7.widget.CardView>



Complete Source Code : CardVewDemo

For any doubts you can comment below, i'll respond ASAP.

No comments:

Post a Comment