Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android重新发布问题_Android_Layout - Fatal编程技术网

Android重新发布问题

Android重新发布问题,android,layout,Android,Layout,请帮帮我 我的xml布局是这样的 <LinearLayout width=fill height=wrap orient=horizontal> <LinearLayout width=0 height=wrap weight=1>...</> <LinearLayout width=0 height=wrap weight=1>...</> <LinearLayout width=0 height=wrap weig

请帮帮我

我的xml布局是这样的

<LinearLayout width=fill height=wrap orient=horizontal>
  <LinearLayout width=0 height=wrap weight=1>...</>
  <LinearLayout width=0 height=wrap weight=1>...</>
  <LinearLayout width=0 height=wrap weight=1>...</>
  <LinearLayout width=wrap height=wrap weight=0>...</>
</LinearLayout>

...
...
...
...
这个膨胀的
main.xml
正是我所需要的——四组均匀分布在屏幕上

但是,当我以[例如]第二个子布局可见性
消失了
开始活动,并在运行时使其可见时,整个根/父布局看起来非常糟糕。子视图[来自子布局]彼此混乱,看起来它们的位置没有重新计算以考虑新的
linearlayout
变得可见

requestLayout()
forceLayout()
没有帮助

如何使根布局执行与活动刚开始时相同的操作?


<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:weightSum="4">

        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1">........</LinearLayout>

        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1">........</LinearLayout>

        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1">........</LinearLayout>

        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1">........</LinearLayout>

</LinearLayout>
........ ........ ........ ........
毕竟我能让它工作。现在所有的更新都正确了,尽管我认为这不是真正的解决方案。我刚刚将重新计算布局可见性的代码移动到
onWindowFocusChanged
回调,并在代码中手动设置
android:weightSum

相信
onSizeChanged
回调也会有帮助。

当代码或布局出现问题时,“伪代码”不是最好的主意。在这里发布您使用的确切布局。设置android:weightSum非常有趣,我会使用它。谢谢