gpt4 book ai didi

安卓 : Z-index of a "RecyclerView.ItemDecoration"

转载 作者:行者123 更新时间:2023-11-29 02:31:01 25 4
gpt4 key购买 nike

我有一个带有 2 个 ItemDecorations 的 RecyclerView。我如何指定每个 ItemDecoration 的高度(z-index),以设置将绘制在另一个之上?

最佳答案

来自documentation for RecyclerView.addItemDecoration() :

Item decorations are ordered. Decorations placed earlier in the list will be run/queried/drawn first for their effects on item views. Padding added to views will be nested; a padding added by an earlier decoration will mean further item decorations in the list will be asked to draw/pad within the previous decoration's given area.

所以基本上,如果你写:

recycler.addItemDecoration(decoration1);
recycler.addItemDecoration(decoration2);

绘图将是:

  1. decoration1.onDraw
  2. decoration2.onDraw
  3. 普通的RecyclerView绘图
  4. decoration1.onDrawOver
  5. decoration2.onDrawOver

这样做的结果是,稍后添加的 ItemDecoration 将绘制在先前添加的那些之上。 z-index 在技术上仍然是相同的,但如果 decoration1 全部绘制为蓝色,而 decoration2 将相同的内容绘制为红色,您会看到红色。

关于安卓 : Z-index of a "RecyclerView.ItemDecoration",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49613806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com