GridLayout - 垂直/水平约束不一致

时间:2016-06-23 16:59:49

标签: android android-gridlayout

我发布这个是因为我找不到我在SO和其他网站上寻找的确切内容。我看了this,但我不确定如何解决这个问题。

当我在我的应用中使用GridLayout时出现问题,每当我旋转屏幕时,我都会看到类似这样的输出:

在横向模式中:

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链接看来它可能会出现性能问题。

我的XML中的GridLayout

<GridLayout
        android:id="@+id/button_grid"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
</GridLayout>

除此之外,我还会在创建应用程序时以编程方式向布局添加视图。

2 个答案:

答案 0 :(得分:3)

GridLayout封闭在ScrollView内后,消息不再出现。

<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>

答案 1 :(得分:0)

我猜你在扩展异步任务类时会出现这个问题! 使用改造代替,屏幕旋转问题将得到解决。

相关问题