Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize cardview?

how can i customize cardview in such a way (the top left one)?

In my way, if i add 3 corored boxes (blue, gray, white) i always get a thin border on the perimeter of the cardview box. Any example? Thanks.

Example

like image 606
SERG Avatar asked Jun 12 '15 07:06

SERG


People also ask

How do I add padding to CardView?

In fact, the Android system does just that: Before L, CardView adds padding to its content and draws shadows to that area. This padding amount is equal to maxCardElevation + (1 - cos45) * cornerRadius on the sides and maxCardElevation * 1.5 + (1 - cos45) * cornerRadius on top and bottom.

What is card view in mad?

Apps often need to display data in similarly styled containers. These containers are often used in lists to hold each item's information. The system provides the CardView API as an easy way for you to show information inside cards that have a consistent look across the platform.


1 Answers

Did you try with relative layout?

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:app="http://schemas.android.com/apk/res-auto"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                        xmlns:app="http://schemas.android.com/apk/res-auto"
                        android:id="@+id/card_view"
                        android:layout_width="match_parent"
                        android:layout_height="230dp"
                        android:layout_marginBottom="@dimen/cardMarginVertical"
                        android:layout_marginLeft="@dimen/cardMarginHorizontal"
                        android:layout_marginRight="@dimen/cardMarginHorizontal"
                        android:layout_marginTop="@dimen/cardMarginVertical"
                        app:cardCornerRadius="2dp"
                        app:cardElevation="2dp"
                        app:cardPreventCornerOverlap="false"
                        app:contentPadding="0dp">

        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">
            <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal">
                <!--Circle image View-->
                <de.hdodenhof.circleimageview.CircleImageView
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_marginLeft="270dp"
                        android:layout_marginTop="220dp"
                        android:id="@+id/circleViewDiscount"
                        android:src="@drawable/border_white"/>

                <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="10.19\nSaturday\n 30th August 2015"
                        android:textSize="23dp"
                        android:textColor="#08ec38"
                        android:id="@+id/textViewPirceTag"/>
            </LinearLayout>

            <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:margin_Top="50dp" <!--Style the height-->
            android:orientation="horizontal"> 
                    <!--Add element here-->
                </LinearLayout>
            </RelativeLayout>    
        </android.support.v7.widget.CardView>    
    </FrameLayout>
like image 64
KZoNE Avatar answered Sep 22 '22 21:09

KZoNE