简体   繁体   中英

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?

在此处输入图像描述

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:

在此处输入图像描述

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM