Android - 在 Recycler View 的一行顶部创建功能区?

标签 android

如下图所示,我想创建一个 Recyclerview,其中每行/卡片 View 都以带状包裹在行上的方式显示“销售”。我已经创建了 recyclerview 并填充了数据。只有“促销”丝带不会出现。

我该怎么做?

enter image description here

最佳答案

您应该使用 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/

相关文章:

java - android - XMLPullParser 错误

android - 无法在android中的单独 TextView 中显示值

android - 以编程方式更改 appWidget 的高度?

android - 如何在 Android Studio 中使用 appcompat-v7 :19. 1

android - linux 上的 android 交叉编译。目标是什么?

android - 如何使用 GDBSERVER 在 Android 上调试应用程序?

java - Android Studio致命异常: java. lang.OutOfMemoryError:无法分配内存

php - 将音频上传到服务器PHP android

java - 从字节更改为短格式再返回字节时,AudioRecorder 质量会下降

android TextView没有换行符