在使用 AndroidX 的 FrameLayout 进行布局时,如果遇到 "layout_heightPercent" 属性未找到的错误,这通常是因为 AndroidX 的 FrameLayout 并没有内置支持百分比布局的属性。解决这个问题的方法有两种:
在上面的示例中,我们使用了 ConstraintLayout 提供的 app:layout_constraintHeight_percent
和 app:layout_constraintWidth_percent
属性来实现百分比布局。
implementation 'com.android.support:percent:28.0.0'
然后,在你的布局文件中使用 "PercentFrameLayout" 来替换原来的 FrameLayout,并使用 "layout_heightPercent" 属性来设置高度的百分比。示例代码如下:
以上是两种解决 AndroidX FrameLayout 布局中 "layout_heightPercent" 属性未找到错误的方法。你可以根据自己的需求选择其中一种方法来解决该问题。