android - 圆形背景 android 的阴影
问题描述
我有一个背景可绘制对象,它只有两个带有半径的角。
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:topLeftRadius="6dp" android:bottomLeftRadius="6dp"></corners>
</shape>
我将它应用于文本视图。我还为它附加了一个大纲提供程序。
<android.support.v7.widget.AppCompatTextView
android:id="@+id/textView71"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="16dp"
android:layout_marginTop="64dp"
android:background="@drawable/left_rounded_border_6dp"
android:backgroundTint="@color/colorAccent"
android:padding="@dimen/unit_medium"
android:elevation="10dp"
android:outlineProvider="bounds"
android:text="Challenge"
android:textAppearance="@style/TextAppearance.Heading5"
android:textColor="@color/colorTextWhite"
app:layout_constraintBottom_toTopOf="@+id/company_logo_iv"
app:layout_constraintEnd_toStartOf="@+id/textView73"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
这是我看到的影子。
仔细观察,您会发现阴影并未完全应用在曲线上。相反,它应用于矩形区域。
我不知道为什么会这样。
解决方案
高程根据视图的轮廓提供程序创建阴影。这默认为背景可绘制的边界 - 这是完美的矩形。
您可以创建和设置自己的圆角轮廓提供程序 - 请参阅https://developer.android.com/training/material/shadows-clipping#Shadows
推荐阅读
- asp.net-mvc - 如何将分组的 Viewbag 绑定到 MVC 视图?
- c# - 在几个应用程序之间共享 WPF 窗口
- java - Spring Boot - 如何将 POST 表单数据 MultipartFile 发送到 Flask 服务器
- python - tensorflow 1.13 如何安全使用 tf.searchsort?
- flask - 结合 Web 应用程序和 api 的用户身份验证最佳实践
- php - 将值 Base64 保存到 Image PNG 使用干预图像 Laravel 存储
- javascript - 如何在反应中自动检查变量是否存在?
- python - 'QueryResult' 对象不可迭代 - 无法将 Dialogflow API 中的值返回到我的聊天机器人
- c# - 使用 if 条件时将两个列表数据添加到数组中
- excel - 在vba中比较负数的问题