GridLayout - Vertical/Horizontal constraints are inconsistent
Asked Answered
A

3

5

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.

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:

In landscape mode:

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.

In portrait mode:

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.

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.

The GridLayout in my XML:

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

Alarcon answered 23/6, 2016 at 16:59 Comment(0)
A
4

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>
Alarcon answered 23/6, 2016 at 16:59 Comment(1)
I did a Clean Build and rebuild and it stopped noting this.Blouse
S
0

Assuming that your Grid Layout is in a constraint layout, I fixed the same issue that I got by setting the width of all elements in my Grid Layout by setting it to 0dp(match constraint).

    <GridLayout
    android:id="@+id/profile_info_grid"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:rowCount="3"
    android:columnCount="2"
    style="@style/UserProfileGridSpace"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/header_card_View"
    app:layout_constraintBottom_toTopOf="@+id/logout_button">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:textStyle="bold"
        style="@style/UserProfileLabelTheme"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:layout_row="0"
        android:layout_column="0"
        android:text="Email address: "/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/email_field"
        style="@style/UserProfileLabelTheme"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        />
    </GridLayout>

Note the width of my text views. Previously it was set to 'wrap_content' and I got the same errror as yours, and the text view didn't therefore appear. I fixed it by doing this! Hope this helps, Cheers!

Snell answered 24/9, 2022 at 2:23 Comment(0)
S
-2

I guess this problem occurs when u you are extending async task class ! Use retrofit instead , screen rotation problem would be solved .

Syndesmosis answered 23/6, 2016 at 17:6 Comment(2)
Not using AsyncTask anywhere in my app.Rubio
Please share the full log cat or the screenshotSyndesmosis

© 2022 - 2024 — McMap. All rights reserved.