Android - Layout时发生'Unfortunately xxx has stopped'
Android 39 has 发生 xxx layout
2023-09-27 14:28:06 时间
概述
我在进行LinearLayout和TableLayout的嵌套布局的时候,发生题的错误.如下布局xml代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 android:layout_width="fill_parent" 3 android:layout_height="fill_parent" 4 android:orientation="vertical" > 5 6 <LinearLayout 7 android:layout_width="fill_parent" 8 android:layout_height="fill_parent" 9 android:layout_weight="1" 10 android:orientation="horizontal" > 11 12 <TextView 13 android:layout_width="wrap_content" 14 android:layout_height="fill_parent" 15 android:layout_weight="1" 16 android:background="#996699" 17 android:gravity="center" 18 android:text="one" /> 19 20 <TextView 21 android:layout_width="wrap_content" 22 android:layout_height="fill_parent" 23 android:layout_weight="1" 24 android:background="#FFFF99" 25 android:gravity="center" 26 android:text="two" /> 27 28 <TextView 29 android:layout_width="wrap_content" 30 android:layout_height="fill_parent" 31 android:layout_weight="1" 32 android:background="#CC9966" 33 android:gravity="center" 34 android:text="three" /> 35 36 <TextView 37 android:layout_width="wrap_content" 38 android:layout_height="fill_parent" 39 android:layout_weight="1" 40 android:background="#CCCC99" 41 android:gravity="center" 42 android:text="four" /> 43 </LinearLayout> 44 45 <LinearLayout 46 android:layout_width="fill_parent" 47 android:layout_height="fill_parent" 48 android:layout_weight="1" 49 android:orientation="vertical" > 50 51 <TableLayout> 52 53 <TableRow> 54 55 <TextView 56 android:layout_width="fill_parent" 57 android:layout_height="wrap_content" 58 android:layout_weight="1" 59 android:background="#993333" 60 android:gravity="center" 61 android:text="five" /> 62 63 <TextView 64 android:layout_width="fill_parent" 65 android:layout_height="wrap_content" 66 android:layout_weight="1" 67 android:background="#CCCCCC" 68 android:gravity="center" 69 android:text="six" /> 70 </TableRow> 71 72 <TableRow> 73 74 <TextView 75 android:layout_width="fill_parent" 76 android:layout_height="wrap_content" 77 android:layout_weight="1" 78 android:background="#FFFF99" 79 android:gravity="center" 80 android:text="seven" /> 81 </TableRow> 82 </TableLayout> 83 </LinearLayout> 84 85 </LinearLayout>
其中,应该在第51行中,TableLayout加上'layout_width'和'layout_height'属性.即可.如下(第46/47行):
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 android:layout_width="fill_parent" 3 android:layout_height="fill_parent" 4 android:orientation="vertical" > 5 6 <LinearLayout 7 android:layout_width="fill_parent" 8 android:layout_height="fill_parent" 9 android:layout_weight="1" 10 android:orientation="horizontal" > 11 12 <TextView 13 android:layout_width="wrap_content" 14 android:layout_height="fill_parent" 15 android:layout_weight="1" 16 android:background="#996699" 17 android:gravity="center" 18 android:text="one" /> 19 20 <TextView 21 android:layout_width="wrap_content" 22 android:layout_height="fill_parent" 23 android:layout_weight="1" 24 android:background="#FFFF99" 25 android:gravity="center" 26 android:text="two" /> 27 28 <TextView 29 android:layout_width="wrap_content" 30 android:layout_height="fill_parent" 31 android:layout_weight="1" 32 android:background="#CC9966" 33 android:gravity="center" 34 android:text="three" /> 35 36 <TextView 37 android:layout_width="wrap_content" 38 android:layout_height="fill_parent" 39 android:layout_weight="1" 40 android:background="#CCCC99" 41 android:gravity="center" 42 android:text="four" /> 43 </LinearLayout> 44 45 <LinearLayout 46 android:layout_width="fill_parent" 47 android:layout_height="fill_parent" 48 android:layout_weight="1" 49 android:orientation="vertical" > 50 51 <TableLayout 52 android:layout_width="fill_parent" 53 android:layout_height="fill_parent" > 54 55 <TableRow> 56 57 <TextView 58 android:layout_width="fill_parent" 59 android:layout_height="wrap_content" 60 android:layout_weight="1" 61 android:background="#993333" 62 android:gravity="center" 63 android:text="five" /> 64 65 <TextView 66 android:layout_width="fill_parent" 67 android:layout_height="wrap_content" 68 android:layout_weight="1" 69 android:background="#CCCCCC" 70 android:gravity="center" 71 android:text="six" /> 72 </TableRow> 73 74 <TableRow> 75 76 <TextView 77 android:layout_width="fill_parent" 78 android:layout_height="wrap_content" 79 android:layout_weight="1" 80 android:background="#FFFF99" 81 android:gravity="center" 82 android:text="seven" /> 83 </TableRow> 84 </TableLayout> 85 </LinearLayout> 86 87 </LinearLayout>
相关文章
- Android Studio 的 10 个你非常有可能不知道的技巧
- Android 解决apk打包过程中出现的“Certificate for <jcenter.bintray.com> doesn't match any of the subject alternative names: [*.aktana.com, aktana.com]”的问题
- Android跨进程通信:图文详解 Binder机制 原理
- 腾讯Android自动化测试实战3.3.3 修改Robotium以支持X5WebView
- Android代码混淆技术总结(一)
- android SQLiteOpenHelper 使用
- Android动画曲线库AndroidEasingFunctions
- android常见错误-The container 'Android Dependencies' references non existing library
- Android改变图片颜色的自定义控件
- 基于 Android NDK 的学习之旅-----序言
- 如何判断Android系统的版本
- Android 实现书籍翻页效果----升级篇
- android上的i-jetty (1)环境搭建
- Android开发--异步加载
- Android Studio报错Error:Failed to open zip file. Gradle's dependency cache may be corrupt