问题
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