Len*_*Bru 22 android view z-order
我想在动画期间更改某些视图的z顺序
在4.1.2以上的机器人上工作得很好,在4.1.2以下的机器人上,Z顺序没有变化,顶视图仍然在顶部.
这就是我想要的.
myView.bringToFront();
((View)myView.getParent()).invalidate();
Run Code Online (Sandbox Code Playgroud)
如何使它在旧设备上运行?
Len*_*Bru 22
/**
* 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 {@link android.os.Build.VERSION_CODES#KITKAT} this
* method should be followed by calls to {@link #requestLayout()} and
* {@link View#invalidate()} on the view's parent to force the parent to redraw
* with the new child ordering.
*
* @see ViewGroup#bringChildToFront(View)
*/
public void bringToFront() {
if (mParent != null) {
mParent.bringChildToFront(this);
}
}
Run Code Online (Sandbox Code Playgroud)
根据这一点,我只是错过了这条线
((View)myView.getParent()).requestLayout();
Run Code Online (Sandbox Code Playgroud)
它工作了!
Col*_*bri 13
我尝试了所有这些.RelativeLayout应该在Button的顶部,但它只是不想服从.
最后,我通过添加android:elevation="2dp"到RelativeLayout来解决它.
高程值仅用于API级别21及更高级别.在我的情况下,API级别21以下的所有内容都很好,上面的所有内容都没有.
希望这可能有助于某人:)
| 归档时间: |
|
| 查看次数: |
19909 次 |
| 最近记录: |