gpt4 book ai didi

android - CardView 忽略 android :clipChildren ="false"

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:05:05 28 4
gpt4 key购买 nike

我想要一个 CardView,其中包含一个与 CardView 的左边框重叠的 ImageView。我想通过给 ImageView 一个负边距来做到这一点。通过设置 clipChildren="false",这适用于所有其他布局 (LinearLayout/RelativeLayout/FrameLayout)。

但是我无法让它与 CardView 一起使用。ImageView 将被剪裁并且不会与 CardView 重叠。

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:clipChildren="false">
<ImageView
android:layout_marginLeft="-10dp"
android:background="@drawable/some_picture"
android:layout_width="50dp"
android:layout_height="50dp"/>
</android.support.v7.widget.CardView>

最佳答案

好的,这个好像只有Android 5+才有问题,解决办法就是设置

cardView.setClipToOutline(false);

来源 - https://www.reddit.com/r/androiddev/comments/2tccge/cant_draw_outside_of_cardview_parent/

关于android - CardView 忽略 android :clipChildren ="false",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32355499/

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