gpt4 book ai didi

android - View 边缘处的 float 操作按钮阴影剪裁

转载 作者:IT老高 更新时间:2023-10-28 23:19:03 25 4
gpt4 key购买 nike

我有一个 float 操作按钮锚定在协调器布局的右下角。它距离 View 的边距 16dp(默认情况下包含边距,并在 dimens.xml 文件中指定),但它的阴影是剪切的并且具有方形外观(见下文)。当我将 float 操作按钮从 View 边缘移动到 32dp 时,它的阴影会正确显示。

我已经尝试设置它的海拔属性(android:elevation="5dp"),但这似乎没有效果。我也尝试将属性borderWidth设置为0(app:borderWidth="0dp"),但这也没有效果。

float 操作按钮出现这样的行为是否有原因?

XML

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<android.support.design.widget.FloatingActionButton
android:id="@+id/create_floating_action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_create_white_48dp"
app:layout_anchor="@id/coordinator_layout"
app:layout_anchorGravity="bottom|right" />

</android.support.design.widget.CoordinatorLayout>

图片

FAB 16dp from the margin. FAB 32dp from the margin.

最佳答案

问题是父级剪辑阴影。寻找裁剪阴影的父级(不一定是层次结构中的下一个)并将其添加到 xml 中的 View 中。

android:clipChildren="false"

我现在一直在对此进行测试,删除该行并将其添加到正在剪切 View 并且工作正常的父级。

添加另一个容器或更改边距是我不推荐的解决方法。太片面了。迷你晶圆厂具有不同的容器尺寸,并且根据 API 级别(<21 或 >=21)需要不同的尺寸。

关于android - View 边缘处的 float 操作按钮阴影剪裁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31507097/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com