顶部容器的圆角,无论儿童视图的背景颜色如何

时间:2018-11-17 01:35:37

标签: android android-layout

我的布局对于不同的Textview具有不同的颜色

  <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizonetal">

    <Textview
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="AAAA"
        android:background="drawable/RED" />

    <Textview
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="BBB"
        android:background="drawable/BLUE" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizonetal">

    <Textview
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="CCC"
        android:background="drawable/ORANGE" />

    <Textview
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="DDD"
        android:background="drawable/GREEN" />
</LinearLayout>
</LinearLayout>

如何使整个布局成为圆角? 如果我创建了一个圆角bg,那么我必须为每个文本视图创建一个具有填充颜色的圆角。但是我不知道我是否可以采用完整的布局,并使其圆角变圆(将矩形的角剪裁一下)。

这是必需的,因为此布局被设置为对话框,并且我希望对话框为圆角

谢谢

这是我的意思的图片。我有这个具有不同颜色的矩形视图/布局。想象一下,由于后面还有其他布局,因此背景为棕色。我怎样才能像第二幅图像那样使切面视图变圆(和透明的角)

enter image description here

1 个答案:

答案 0 :(得分:0)

我找到了答案。我需要使用cardview作为根布局并设置拐角,它将覆盖所有子边界