android - ImageView拒绝父级的圆角和边框
问题描述
我有多个孩子的视图我想给整个小组这样的圆角:
我试图通过它们的背景给父 LinearLayout 和它的 ImageView 圆角来做到这一点
线性布局和孩子:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/tile_background"
android:elevation="1dp"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/image_frame_sponsorship"
android:coverTileUrl="@{sponsorship.coverTileUri}">
</ImageView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:paddingLeft="20dp">
<TextView
android:id="@+id/postActionText"
style="@style/ActionFont"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
tools:text="@string/watch_respond">
</TextView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/ic_chevron_right_black_36dp">
</ImageView>
</RelativeLayout>
</LinearLayout>
线性布局背景:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<stroke
android:width="1dp"
android:color="#D2DADC" />
<corners android:radius="10dp" />
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
</shape>
ImageView 背景:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
<solid android:color="@android:color/white" />
<stroke
android:width="1dp"
android:color="@color/white" />
</shape>
LinearLayout 采用圆角,但 imageView 的前两个角没有,溢出角,显然是其父级的边框:
如何使 ImageView 表现良好?
解决方案
使imageview的所有角落都变圆。底部将隐藏在线性布局的后面。
推荐阅读
- mysql - 如何在我现有的 SQL 语句中添加第二个条件?
- java - 当活动被破坏时保存切换按钮的值,并在活动再次开始时将它们放回原处
- ios - 跨多个子视图的 SwiftUI 拖动手势
- java - 类不能解析为类型?
- reactjs - 使用全局 js 文件的状态管理,而不使用 React 中的任何库
- django - 是否有 django 函数将数据库中的对象传递到 django 视图中的下一个重定向页面
- c++ - 对如何对双链表进行深拷贝感到困惑?
- django - 编辑模式下的图像字段仍然要求图像作为 django 表单中的“必填”字段
- ios - 如何在自动布局中使用 UITableViewCell 的动态高度并在底部视图隐藏时将其他视图向上移动?
- javascript - 从 utils 文件中的函数返回值到反应组件中的状态