【发布时间】:2020-09-21 17:25:54
【问题描述】:
【问题讨论】:
-
android:background="@drawable/abc_menu_dropdown_panel_holo_light"
【问题讨论】:
android:background="@drawable/abc_menu_dropdown_panel_holo_light"
您可以使用碳获得彩色阴影
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
}
}
要将 Carbon 与 ProGuard 一起使用,请将以下规则添加到您的 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>
卡片视图:
<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>
【讨论】: