Note : Before getting started you must setup CardView into your Android Studio.
Please check out my tutorial which shows how to setup Cardview.
Setup CardView
Copy paste this code in your XML layout file :
<android.support.v7.widget.CardView
android:id="@+id/btn_create_event"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:elevation="5dp"
app:cardCornerRadius="25dp"
app:cardBackgroundColor="@color/colorPrimary"
android:innerRadius="0dp"
android:shape="ring"
android:layout_gravity="left"
app:cardUseCompatPadding="true"
android:clickable="true"
android:thicknessRatio="1.9"
android:layout_centerHorizontal="true"
android:foreground="?attr/selectableItemBackground"
android:onClick="methodtoexecute"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="20dp"
android:paddingRight="40dp"
>
<ImageView
android:id="@+id/img_create_event_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:src="@drawable/ic_white_correct" />
<TextView
android:id="@+id/lbl_createEvent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save & Continue"
android:textSize="18dp"
android:layout_marginLeft="10dp"
android:textColor="@color/white"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/img_create_event_icon"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
Where ,
methodtoexecute : Method available in your corresponding Java class.
In you corresponding java file place following code :
public void methodtoexecute(View view){
//Your code goes here
}
Thank you
Please visit again
Subscribe for latest post.
No comments:
Post a comment