是否有一种简单的方法可以在回收站 View 中屏蔽项目? 我制作了一个带有灰色笔划且角半径为 20 的可绘制实体。 笔触在顶部/底部/侧面看起来不错,但圆角被回收站的元素切掉了。
是否有解决此问题的通用做法?
最佳答案
我刚遇到同样的问题,我知道这个答案晚了 8 个月,但我仍然会提供我的想法。
对于我的 RecyclerView,其中我已经有带圆角的图标,我将其用作背景:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:bottomLeftRadius="40dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="40dp"
/>
<size
android:width="480dp"
android:height="480dp"/>
<solid
android:color="@color/colorAccent"/>
</shape>
然后,我用它作为前景(它像面具一样工作):
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:bottomLeftRadius="40dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="40dp"
/>
<size
android:width="500dp"
android:height="500dp"/>
<stroke
android:width="10dp"
android:color="@color/colorAccent"/>
</shape>
然后您可以调整轮廓的厚度,并向 RecyclerView 添加一些填充。
希望这对您有所帮助,^_^。
快乐编码;
关于android - 使用可绘制对象(背景)在回收站 View 中屏蔽项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48062066/