Android bringToFront() View API <= 16

你离开我真会死。 提交于 2019-12-11 01:11:33

问题


When I was testing my app, I realized that if I use a device with API <= 16 the method bringToFront() does not work! How can I do this for APIs less than 16? When I touch a view, I need to bring it to the front! With API 17 or greater, bringToFront() works.

Thanks


回答1:


Just by using the documentation you can read there (http://developer.android.com/reference/android/view/View.html) that:

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.

So it does work on early APIs, it's just that you should use it a little bit differently ;)




回答2:


From the 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.



来源:https://stackoverflow.com/questions/33136961/android-bringtofront-view-api-16

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!