Search code examples
androiduser-interfaceviewandroid-recyclerviewandroid-components

How can I attach this triangle with cardview in Android?


is there any specific component in Android or I have to use view to make triangle (showing in round in image) and attach to card but still as I uploaded image it would not be as same as in image.
Image


Solution

  • Well there are many approaches , but mine is :

    You will create an Image like that in photoshop (Of course measure it well and Target all devices (dp)), then place it inside your drawable folder , and call it on top of your CardView.

    Suppose that image is called image_traingle.jpg you can do it this way

    <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:onClick="Contract"
            android:layout_margin="10dp"
            app:cardCornerRadius="7dp"
            android:layout_height="90dp">
    
            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <Imageview
                    android:layout_width="wrap_content"
                    android:gravity="left"
                    android:background="@color/colorPrimary"
                    android:src="drawable/image_triangle"
                    android:layout_height="match_parent" />
    
                      .
                      .
                      .
            </LinearLayout>
    
    
        </android.support.v7.widget.CardView>