[英]Android - Create a ribbon on top of a row of a Recycler View?
As shown in the below image, I want to create a Recyclerview with each row/ card view showing "Sale" in a ribbon style wrapped over the row. 如下图所示,我想创建一个Recyclerview,其中每一行/卡片视图都以包裹在该行上的功能区样式显示“Sale”。 I have already created the recyclerview and populated the data.
我已经创建了recyclerview并填充了数据。 Only the "Sale" ribbon is not coming.
只有“促销”功能区才会出现。
How do I do it? 我该怎么做?
You should use RelativeLayout
for this task. 您应该使用
RelativeLayout
执行此任务。
Put your card's content into a LinearLayout
(call contentView this time) and give it some layout_margin
. 将你的卡的内容放入
LinearLayout
(这次调用contentView)并给它一些layout_margin
。 Then put this content view into a RelativeLayout
and add the sale ribbon as an ImageView
child element. 然后将此内容视图放入
RelativeLayout
并将销售功能区添加为ImageView
子元素。 Like this: 像这样:
<?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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.