简体   繁体   English

如何制作带阴影的圆角边框

[英]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 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:将语言兼容性选项添加到 build.gradle:

android {
...

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

add data binding support to build.gradle:为 build.gradle 添加数据绑定支持:

android {
...

dataBinding {
    enabled = true
   }
}

to use Carbon with ProGuard add the following rules to your ProGuard:要将 Carbon 与 ProGuard 一起使用,请将以下规则添加到您的 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:你可以在carbon的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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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