Android bringToFront() 视图 API <= 16

Android bringToFront() View API <= 16

当我测试我的应用程序时,我意识到如果我使用 API <= 16 的设备,方法 bringToFront() 将不起作用!对于 API 小于 16 岁的人,我该如何做到这一点?当我触摸一个视图时,我需要将它带到前面! API 17 或更大时,bringToFront() 有效。

谢谢

来自documentation

public void bringToFront () Added in API level 1

Change the view's z order in the tree, so it's on top of other sibling views. This ordering change may affect layout, if the parent container uses an order-dependent layout scheme (e.g., LinearLayout). Prior to KITKAT this method should be followed by calls to requestLayout() and invalidate() on the view's parent to force the parent to redraw with the new child ordering.

只需使用文档,您就可以在此处阅读 (http://developer.android.com/reference/android/view/View.html):

Change the view's z order in the tree, so it's on top of other sibling views. This ordering change may affect layout, if the parent container uses an order-dependent layout scheme (e.g., LinearLayout). Prior to KITKAT this method should be followed by calls to requestLayout() and invalidate() on the view's parent to force the parent to redraw with the new child ordering.

所以它确实适用于早期的 API,只是您应该以不同的方式使用它 ;)