我有一个框架布局,有 2 个 child 。自定义 View 和进度条。
一次只能看到 1 个。按我的需要工作。
我还想添加一些错误 View ,它将显示错误并隐藏其他组件。
使用 FrameLayout 是个好主意还是我应该切换到 RelativeLayout?
最佳答案
如果布局适合您,我会坚持使用 FrameLayout
。由于只有 3 个 child (并假设他们都没有 child ),性能上的差异应该非常小(如果有的话),但我注意到一个区别,即深入研究 FrameLayout
和RelativeLayout
在onMeasure
方法中,FrameLayout
会迭代两次它的所有children,RelativeLayout
从3迭代到7次 (!)
你可以查看 FrameLayout onMeasure和 RelativeLayout onMeasure你自己
关于android - 显示 View /进度微调器/错误 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42489808/