如何把一个以正面没有调用bringToFront()? [英] How to bring a view to front without calling bringToFront()?

查看:928
本文介绍了如何把一个以正面没有调用bringToFront()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然有一个<一个href="http://groups.google.com/group/android-developers/browse_thread/thread/c9b74dc80c26a5a2">bug在Android的打破 View.bringToFront

There is apparently a bug in Android which breaks View.bringToFront.

如果我有安排在一个GridView意见,并希望通过调用bringToFront()把视角的面前,它可能会移动到GridView的右下角位置。

If I have Views arranged in a GridView and want to bring a View to front by calling bringToFront(), it may get moved to the bottom right position in the GridView.

有什么见不得人的事情出现,所以我不能用bringToFront()。如果我不叫了,一切工作正常。但观重叠 - 如果我使用规模的动画来扩展视图,它部分由视图的底部和右侧遮蔽

Something shady is going on there, so I can't use bringToFront(). When I don't call it, everything works fine. But the Views overlap - if I use scale animation to scale up a View, it's partially obscured by the Views to the bottom and to the right.

我已经签出bringToFront的来源,它调用parent.bringChildToFront(...)

I've checked out bringToFront's source and it calls parent.bringChildToFront(...)

这是这个方法

public void bringChildToFront(View child) {
     int index = indexOfChild(child);
      if (index >= 0) {
          removeFromArray(index);
          addInArray(child, mChildrenCount);
          child.mParent = this;
      }
  }

它显然删除查看从本身!毫不手软!是一个ViewGroup中这样愚蠢的,它不能管理Z-指数以任何其他方式洗牌周围的控制?显然,当GridView控件删除其子,然后再次将其添加回,它被放置在电网的末端!

it apparently removes the View from itself! Without mercy! Is a ViewGroup so dumb that it can't manage Z-indexes in any other way that shuffling controls around? Obviously when GridView removes its child and then adds it back again, it gets placed at the end of the Grid!

有什么我可以做,以显示在别人的顶部视图而不是诉诸一些黑客?浮现在我的脑海里有一件事是创建GridView控件,这将显示为上面的那个我想bringToFront()上面的另一种观点,但我不喜欢这样的解决方案。

Is there anything I can do to show a View on top of others without resorting to some hacking? One thing that comes to my mind is to create another View above the GridView, which will appear to be above the one I'm trying to bringToFront(), but I don't like this solution.

推荐答案

显然我错过了安卓clipChildren =假属性GridView控件。它解决了我的问题。

apparently I missed the android:clipChildren="false" property in GridView. It solves my problem.

这篇关于如何把一个以正面没有调用bringToFront()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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