Wednesday, 29 July 2015

ANDROID STUDIO: CardView Layout

-
ANDROID STUDIO: CardView Layout
1) Run Android Studio
2) Create a new Android Studio Project
2) Create New Project
3) Update Build.Gradle (Module:App) File
4) Edit Layout File
5) Rebuild Project
6) Card View Layout Done.

1) Run Android Studio

2) Create a new Android Studio Project

MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 3.03.29 PM.png

2) Create New Project

 MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 3.04.25 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 10.02.35 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 3.07.37 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 3.08.57 PM.png

3) Update Build.Gradle (Module:App) File

Edit cardview compile codes in dependencies section:
compile 'com.android.support:cardview-v7:21.0.+'

4) Edit Layout File

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
   android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

   <TextView android:text="@string/hello_world" android:layout_width="wrap_content"
       android:layout_height="wrap_content" />
   <android.support.v7.widget.CardView
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:id="@+id/cv"
       >

       <RelativeLayout
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:padding="16dp"
           >

           <ImageView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:id="@+id/person_photo"
               android:layout_alignParentLeft="true"
               android:layout_alignParentTop="true"
               android:layout_marginRight="16dp"
               android:background="@mipmap/ic_launcher" />

           <TextView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:id="@+id/person_name"
               android:layout_toRightOf="@+id/person_photo"
               android:layout_alignParentTop="true"
               android:textSize="30sp"
               android:autoText="false"
               android:text="test" />

           <TextView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:id="@+id/person_age"
               android:layout_toRightOf="@+id/person_photo"
               android:layout_below="@+id/person_name"
               android:text="123" />

       </RelativeLayout>

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

</RelativeLayout>

5) Rebuild Project

MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 9.53.56 PM.png

6) Card View Layout Done.


-

2 comments:

  1. The information you have posted is very useful. The sites you have referred was good. Thanks for sharing.. vShare iOS 11

    ReplyDelete
  2. Absolutely fantastic posting! Lots of useful information and inspiration, both of which we all need!Relay appreciate your work. Pangu

    ReplyDelete