0

how to create this type of layout in android look like image

enter image description here:

ADM
  • 20,406
  • 11
  • 52
  • 83
Darshi Domadiya
  • 267
  • 3
  • 13

4 Answers4

4

use MaterialCardView and use cardElevation

add this in gradle file to use material components

implementation 'com.google.android.material:material:1.2.0-alpha03'

style.xml

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

in your xml

 <com.google.android.material.card.MaterialCardView
            android:id="@+id/card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:strokeWidth="1dp"
            app:strokeColor="@color/stroke_color"
            app:cardElevation="10dp"
            android:layout_margin="8dp">

            //add some view

        </com.google.android.material.card.MaterialCardView>
Jaydeep chatrola
  • 2,423
  • 11
  • 17
0

I think you can try to use cardView and add onclick func to act as a button

Inside the cardView, you need to customize the layout of TextView, ImageView and other UI you want.

https://guides.codepath.com/android/using-the-cardview

https://material.io/develop/android/components/cards/

For button shadow, I guess cardView can add shadow too

How to add shadow on CardView aligned to bottom of parent

Donald Wu
  • 698
  • 7
  • 20
0

Did u try: android:elevation="3dp" in view xml? let try.

Hope this help!

Chuong Le Van
  • 274
  • 1
  • 8
0
<androidx.cardview.widget.CardView
        android:id="@+id/maincard"
        android:layout_width="@dimen/_250sdp"
        android:layout_height="@dimen/_150sdp"
        android:layout_marginStart="@dimen/_5sdp"
        android:layout_marginEnd="@dimen/_15sdp"
        app:cardCornerRadius="@dimen/_12sdp"
        app:cardElevation="@dimen/_10sdp"
        app:cardPreventCornerOverlap="false">
Jaimil Patel
  • 1,301
  • 6
  • 13