英文:
android bring to front not working on card view
问题
在安卓中,当尝试将一个视图置于卡片视图之前时,bringToFront()
方法无法正常工作。似乎卡片视图始终比其他视图具有更高的优先级。我尝试过同时使用 requestLayout()
和 bringToFront()
,但没有效果。有没有关于如何解决这个问题的想法?我尝试过使用 elevation
,但在安卓 API 版本低于 21 的情况下不起作用。
view.post(() -> {
view.setVisibility(View.VISIBLE);
view.bringToFront();
view.requestLayout();
});
英文:
In android bringToFront()
not working when trying to bring a view to the front of a card view. 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. 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.
view.post(() -> {
view.setVisibility(View.VISIBLE);
view.bringToFront();
view.requestLayout();
});
答案1
得分: 1
最终的解决方案是使用FrameLayout。如果任何人想要在CardView前加载一个视图,必须将CardView放入FrameLayout中。没有FrameLayout,CardView会始终获得更高的高度和显示中的平移。
英文:
finally the solution was using FrameLayout. if anyone wants to load a view in front of a cardView it must put cardView in a frameLayout. without frameLayout cardView always get a higher elevation and translation in show
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论