GridLayout - Vertical/Horizontal constraints are inconsistent

匿名 (未验证) 提交于 2019-12-03 01:12:01

问题:

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.

回答1:

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> 


回答2:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!