反向的FrameLayout [英] FrameLayout in reverse
问题描述
我试图弄清楚如何更改FrameLayout堆叠其子级的方式.
当前是最新的(FIFO).我想更改它,以使最新的孩子在最下面(FILO).我尝试浏览一下FrameLayout的源代码,但似乎可以找到有关如何将其堆叠为子元素的任何线索.
起初,我以为getLayoutDirection()
是我要寻找的,但这仅涉及RTL/LTR的可访问性.
使用setChildrenDrawingOrderEnabled(true)
并使用以下内容覆盖getChildDrawingOrder
:
@Override
protected int getChildDrawingOrder(int childCount, int i) {
return childCount - 1 - i;
}
请查看我从您的代码中提取的叉子并进行测试./p>
I'm trying to figure out how to alter the way FrameLayout stacks it's children.
Currently it is newest on top (FIFO). I'd like to change it such that the newest child is on the bottom (FILO). I tried looking through the source code for FrameLayout but I can seem to find any clues on how it stacks it's child elements.
At first I thought getLayoutDirection()
is what I was looking for but that only pertains to RTL/LTR for accessibility.
Use setChildrenDrawingOrderEnabled(true)
and override getChildDrawingOrder
with:
@Override
protected int getChildDrawingOrder(int childCount, int i) {
return childCount - 1 - i;
}
Please, take a look at the fork I did from your code and test it.
这篇关于反向的FrameLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!