XML android中具有圆形底部的背景图像

问题描述 投票:-1回答:1

我想在线性布局的背景中添加图片,并且我知道该属性将为android:background =“ @ drawable / login_bg”,但现在我必须创建一个可绘制的资源文件,并且在该文件中,我想要左下和右下角变圆角,左上和右角变矩形。记住:我需要在背景内带有圆角的图像

I have tried
 https://stackoverflow.com/questions/21002224/add-a-background-image-to-shape-in-xml-android




<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

 <item>
        <shape android:shape="rectangle" android:padding="10dp">
            <corners
                android:bottomRightRadius="15dp"
                android:bottomLeftRadius="15dp"
                android:topLeftRadius="0dp"
                android:topRightRadius="0dp"/>
        </shape>
    </item>
    <item android:drawable="@drawable/login_bg" />
</layer-list>
android android-layout android-xml
1个回答
0
投票

您可以在CardView中使用LinearLayout

<android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="200dp"
        app:cardElevation="0dp"
        app:cardCornerRadius="10dp">
    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/grims">

<!--            Other Views here goes here-->

    </LinearLayout>
</android.support.v7.widget.CardView>

有时您无法在布局预览中看到曲线,但是它肯定可以在设备上使用。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.