简体   繁体   English

android带到前面不能在卡片视图上工作

[英]android bring to front not working on card view

In android bringToFront() not working when trying to bring a view to the front of a card view.在尝试将视图带到卡片视图的前面时,android 中的bringToFront()不起作用。 It seems that the card view always has a higher priority than other views.似乎卡片视图总是比其他视图具有更高的优先级。 I try requestLayout() plus bringToFront() too but it doesn't work.我也试过requestLayout()加上bringToFront()但它不起作用。 Is there any idea on how to solve this problem?关于如何解决这个问题有什么想法吗? I tried to use elevation but it does not work on android below API level 21.我尝试使用elevation但它在 API 级别 21 以下的 android 上不起作用。

view.post(() -> {
    view.setVisibility(View.VISIBLE);
    view.bringToFront();
    view.requestLayout();
});

finally the solution was using FrameLayout.最后的解决方案是使用 FrameLayout。 if anyone wants to load a view in front of a cardView it must put cardView in a frameLayout.如果有人想在 cardView 前面加载视图,则必须将 cardView 放在 frameLayout 中。 without frameLayout cardView always get a higher elevation and translation in show没有 frameLayout cardView 总是在展示中获得更高的高度和平移

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM