反向的FrameLayout [英] FrameLayout in reverse

查看:65
本文介绍了反向的FrameLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚如何更改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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆