gpt4 book ai didi

android - 如何在 CardView 的自定义形状中隐藏阴影?

转载 作者:行者123 更新时间:2023-12-05 07:45:47 36 4
gpt4 key购买 nike

我一直在做一个项目,要求我在 卡片 View 的边上有一个半圆形切口。我已经尝试了很多次。我请求专家帮助我进行侧切和阴影去除。我的输出:

查看我的代码输出

enter image description here

理想输出

enter image description here

代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="20dp"
card_view:cardElevation="8dp"
card_view:cardMaxElevation="10dp"
card_view:cardBackgroundColor="#fff"
android:background="#a9a9a9"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="33dp"
android:id="@+id/view"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-22dp"
android:background="@drawable/coupon_border"
android:layout_gravity="center_vertical" />

<ImageView
android:layout_width="80dp"
android:id="@+id/img1"
android:layout_height="80dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:layout_marginTop="25dp"
android:src="@drawable/sample1"
android:layout_marginBottom="30dp"/>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is a long title."
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
android:layout_marginRight="40dp"
android:textColor="#605f5f"
android:textSize="16dp"
android:layout_alignTop="@+id/view"
android:layout_centerHorizontal="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:layout_marginRight="40dp"
android:text="Lorem ipsum dolor sit amet, justo habemus partiendo id has, et stet labore mediocrem pro. "
android:maxLines="2"
/>

</LinearLayout>

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




</RelativeLayout>

优惠券边框 xml 文件:

  <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false" >
<stroke
android:width="2dip"
android:color="#a9a9a9"/>
<size
android:height="30dp"
android:width="30dp" />
</shape>

最佳答案

试试这个,希望这会起作用。

<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="20dp"
card_view:cardElevation="0dp"
card_view:cardBackgroundColor="#fff"
android:background="#a9a9a9"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="33dp"
android:id="@+id/view"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">

关于android - 如何在 CardView 的自定义形状中隐藏阴影?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41341425/

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