Eman Ahmed
Eman Ahmed

Reputation: 23

How to make rounded border with shadow

How can i make a view like this at bottom of screen ? I can make a view with round border but what about the green shadow ?

enter image description here

Upvotes: 0

Views: 225

Answers (1)

Roya Rastgar
Roya Rastgar

Reputation: 143

you can get colored shadow using carbon

https://github.com/ZieIony/Carbon

add the following line to dependencies:

 api 'tk.zielony:carbon:0.16.0.1'

add language compatibility options to build.gradle:

android {
...

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }
 }

add data binding support to build.gradle:

android {
...

dataBinding {
    enabled = true
   }
}

to use Carbon with ProGuard add the following rules to your ProGuard:

-dontwarn carbon.BR
-dontwarn carbon.internal**
-dontwarn java.lang.invoke**

-dontwarn android.databinding.**
-keep class android.databinding.** { *; }

you can find the following image and code in carbon's github:

enter image description here

code:

<carbon.widget.LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

<carbon.widget.Button
    android:layout_width="56dp"
    android:layout_height="56dp"
    android:layout_margin="@dimen/carbon_padding"
    android:background="#ffffff"
    app:carbon_cornerRadius="2dp"
    app:carbon_elevation="8dp"
    app:carbon_elevationShadowColor="@color/carbon_red_700"/>

</carbon.widget.LinearLayout>

cardview:

<carbon.widget.LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

<carbon.widget.LinearLayout
    android:layout_width="match_parent"
    android:layout_height="160dp"
    android:layout_margin="@dimen/carbon_margin"
    android:background="#ffffff"
    app:carbon_cornerRadius="2dp"
    app:carbon_elevation="8dp"
    app:carbon_elevationShadowColor="@color/carbon_red_700">

    <carbon.widget.ImageView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:src="@drawable/test_image"/>

    <carbon.widget.TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="test text"/>
    </carbon.widget.LinearLayout>

</carbon.widget.LinearLayout>

Upvotes: 2

Related Questions