GridLayout-垂直/水平约束不一致 [英] GridLayout - Vertical/Horizontal constraints are inconsistent
问题描述
我之所以发布此信息,是因为我无法在SO和网络的其余部分上找到真正想要的东西.我查看了此,但是我不确定如何解决该问题.
I'm posting this because I couldn't find exactly what I was looking for on SO and the rest of the web. I had a look at this, but I wasn't exactly sure how to solve the problem.
当我在应用程序中使用GridLayout
时出现了问题,每当旋转屏幕时,都会看到类似以下的输出:
The issue surfaced while I was using GridLayout
in my app and whenever I rotated my screen, I would see an output something like this:
在横向模式下:
06-23 21:41:25.627 10222-10222/in.cryf.yaca D/android.widget.GridLayout: vertical constraints: y1-y0>=112, y2-y1>=112, y3-y2>=112, y4-y3>=112, y4-y0<=311 are inconsistent; permanently removing: y4-y0<=311.
在纵向模式下:
06-23 21:41:28.124 10222-10222/in.cryf.yaca D/android.widget.GridLayout: horizontal constraints: x1-x0>=192, x2-x1>=192, x3-x2>=192, x4-x3>=192, x4-x0<=704 are inconsistent; permanently removing: x4-x0<=704.
尽管它不会影响我的应用程序的运行,但是从我上面发布的SO链接看来,它可能会出现性能问题.
Though it doesn't affect the running of my app, from the SO link I posted above it seems that it can have performance issues.
我的XML中的GridLayout
:
<GridLayout
android:id="@+id/button_grid"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</GridLayout>
除此之外,在创建我的应用时,我还以编程方式将视图添加到布局中.
In addition to this, I programmatically add views to the layout when my app is created.
推荐答案
将我的GridLayout
放在ScrollView
内之后,消息不再出现.
After enclosing my GridLayout
inside a ScrollView
, the message didn't come anymore.
<ScrollView
android:layout_below="@id/output"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<GridLayout
android:id="@+id/button_grid"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</GridLayout >
</HorizontalScrollView>
</ScrollView>
这篇关于GridLayout-垂直/水平约束不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!