如下图所示,我想创建一个 Recyclerview,其中每行/卡片 View 都以带状包裹在行上的方式显示“销售”。我已经创建了 recyclerview 并填充了数据。只有“促销”丝带不会出现。
我该怎么做?
最佳答案
您应该使用 RelativeLayout
来完成这项任务。
将卡片内容放入 LinearLayout
(这次调用 contentView)并给它一些 layout_margin
。然后将此内容 View 放入 RelativeLayout
并将销售功能区添加为 ImageView
子元素。
像这样:
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:background="@color/white">
__content_of_the_card__
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ribbon"/>
</RelativeLayout>
关于Android - 在 Recycler View 的一行顶部创建功能区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40463485/