android - 如何创建类似于 WhatsApp 中的项目分隔符?
问题描述
如何在 WhatsApp 中的 recyclerview 元素之间创建项目分隔符?
我尝试了下面链接中给出的 SimpleItemDecorator 类,但没有给我预期的结果:
解决方案
<?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="@dimen/_60sdp"
android:background="@color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_small">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/msgimage"
android:layout_width="@dimen/_50sdp"
android:layout_height="@dimen/_50sdp"
android:layout_alignParentStart="true"
android:src="@drawable/adpost_placeholder" />
<LinearLayout
android:id="@+id/textsec"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/msgimage"
android:layout_toStartOf="@+id/follosec"
android:orientation="vertical">
<com.codinghands.pistachio.Custom.MyTextViewRegular
android:id="@+id/msgusername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_extra_very_small"
android:layout_marginTop="@dimen/margin_small"
android:text="name"
android:textColor="@color/text_black"
android:textSize="@dimen/text_small"
android:textStyle="bold" />
<com.codinghands.pistachio.Custom.MyTextViewRegular
android:id="@+id/msgfullname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_extra_very_small"
android:paddingEnd="@dimen/padding_small"
android:text="name"
android:textColor="@color/text_lightgrey"
android:textSize="@dimen/text_very_small" />
</LinearLayout>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="@dimen/_60sdp"
android:layout_marginEnd="@dimen/padding_small"
android:layout_alignParentBottom="true"
android:background="#000000" />
</RelativeLayout>
**it will be something like this change margin,padding,color and textview to your need. use it as item in recyclerview **
检查它是否在 bindholder 中的 lastpotion 并隐藏视图以删除 lastposition 的项目分隔符
推荐阅读
- html - 将单个图像缩放成网格正方形?
- c - scanf 和 printf 没有按顺序执行
- reporting-services - SSRS 2015 在两次参数更改后挂起
- spring - Spring cloud config客户端找不到PropertySource
- apache-spark - Apache Spark 如何对大文件的数据进行分区
- java - 我可以在 Web 视图(android)中将 Applet 放入 html 代码中吗
- python - 调用存储函数或过程不会插入和保留更改
- javascript - 根据所选选项 javascript 动态更改跨度文本
- javascript - React:第一次,未定义的错误,但重新加载后,它成功
- python - UnicodeDecodeError:“utf8”编解码器无法解码位置 51 中的字节 0x89:无效的起始字节