英文:
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 ?
答案1
得分: 2
你可以使用Carbon来获得带有颜色阴影的效果。
GitHub链接:https://github.com/ZieIony/Carbon
将以下行添加到依赖项中:
api 'tk.zielony:carbon:0.16.0.1'
在 build.gradle 中添加语言兼容性选项:
android {
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
在 build.gradle 中添加数据绑定支持:
android {
    ...
    dataBinding {
        enabled = true
    }
}
要使用ProGuard与Carbon,请将以下规则添加到ProGuard配置中:
-dontwarn carbon.BR
-dontwarn carbon.internal**
-dontwarn java.lang.invoke**
-dontwarn android.databinding.**
-keep class android.databinding.** { *; }
你可以在Carbon的 GitHub 中找到以下图片和代码:
代码示例:
<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>
英文:
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。



评论