问题描述
我有一个有多个孩子的视图,我想给整个小组这样的圆角:
I have a View with multiple children I would like to give the entire group rounded corners like this:
我正在尝试通过背景的父级LinearLayout及其ImageView圆角来做到这一点
I am attempting do do this by giving both the parent LinearLayout and its ImageView Rounded corners via their backgrounds
LinearLayout和子级:
LinearLayout and children:
<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>
LinearLayout背景:
LinearLayout background:
<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背景:
ImageView background:
<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的顶部两个角没有,溢出了这些角,并且显然是其父级的边框:
The LinearLayout takes on a the rounded corners, but the top two corners of the imageView do not, overflowing the corners and apparently the borders of its parent:
如何使ImageView表现出来?
How do I make the ImageView behave?
推荐答案
对imageview的所有角进行四舍五入.底部将隐藏在linearlayout的后面.
Make all the corners of imageview rounded. Bottom of that will be hide back of linearlayout.
这篇关于ImageView拒绝父对象的圆角和边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!