android xml布局文件的问题

zhangyikai321 2016-03-30 03:29:21
我在对原有系统的xml进行布局但是布局以后我发现系统没办法调用xml文件了但是没修改之前是可以的 这是什么问题
修改后的xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tool11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:background="@drawable/tool11" >
<LinearLayout
android:layout_width="match_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:orientation="horizontal" >

<SeekBar
android:id="@+id/seekBar1"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dip"
android:max="30" >
</SeekBar>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:orientation="horizontal" >

<imagebutton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg_fhzl1" />

<imagebutton
android:id="@+id/ImageButton02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg_lsct1" />

<imagebutton
android:id="@+id/ImageButton03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg_sjzx1" />
</LinearLayout>
</RelativeLayout>

修改前的xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tool11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:background="@drawable/tool11" >

<SeekBar
android:id="@+id/seekBar1"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dip"
android:max="30" >
</SeekBar>

</RelativeLayout>

toolpop1 = this.getLayoutInflater().inflate(R.layout.tool11, null);
toolpop1获取的是空的 然后系统就会退出去这是什么原因造成的 之前我打算新建一个xml但是也是获取不到这些东西
...全文
210 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
sparkhuu 2016-03-31
  • 打赏
  • 举报
回复
LinearLayout没有设置高度
zhangyikai321 2016-03-31
  • 打赏
  • 举报
回复
引用 4 楼 a511341250 的回复:
Binary XML file line #9: You must supply a layout_height attribute. LinearLayout 缺少layout_height
我修改过了 但是他还是imagebutton那部分就出错 还是获取不到的 inflating class imagebutton出现这个 xml文件上面错误的地方但是不添加这个的话获取又是可以
xingzhong128 2016-03-31
  • 打赏
  • 举报
回复
引用 7 楼 zhangyikai321 的回复:
[quote=引用 4 楼 a511341250 的回复:] Binary XML file line #9: You must supply a layout_height attribute. LinearLayout 缺少layout_height
我修改过了 但是他还是imagebutton那部分就出错 还是获取不到的 inflating class imagebutton出现这个 xml文件上面错误的地方但是不添加这个的话获取又是可以 [/quote] <imagebutton 改成 ImageButton android:id="@+id/ImageButton01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg_fhzl1" />
xingzhong128 2016-03-30
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tool11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:background="@drawable/tool11" > <LinearLayout android:layout_width="match_parent" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:orientation="horizontal" > 缺了layout_height <SeekBar android:id="@+id/seekBar1" android:layout_width="180dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="28dip" android:max="30" >
水的川 2016-03-30
  • 打赏
  • 举报
回复
LinearLayout 缺少layout_height 楼上正解~
ESC尛蜜蜂 2016-03-30
  • 打赏
  • 举报
回复
Binary XML file line #9: You must supply a layout_height attribute. LinearLayout 缺少layout_height
zhangyikai321 2016-03-30
  • 打赏
  • 举报
回复
引用 楼主 zhangyikai321 的回复:
我在对原有系统的xml进行布局但是布局以后我发现系统没办法调用xml文件了但是没修改之前是可以的 这是什么问题 修改后的xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tool11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:background="@drawable/tool11" > <LinearLayout android:layout_width="match_parent" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:orientation="horizontal" > <SeekBar android:id="@+id/seekBar1" android:layout_width="180dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="28dip" android:max="30" > </SeekBar> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:orientation="horizontal" > <imagebutton android:id="@+id/ImageButton01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg_fhzl1" /> <imagebutton android:id="@+id/ImageButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg_lsct1" /> <imagebutton android:id="@+id/ImageButton03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg_sjzx1" /> </LinearLayout> </RelativeLayout> 修改前的xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tool11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:background="@drawable/tool11" > <SeekBar android:id="@+id/seekBar1" android:layout_width="180dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="28dip" android:max="30" > </SeekBar> </RelativeLayout> toolpop1 = this.getLayoutInflater().inflate(R.layout.tool11, null); toolpop1获取的是空的 然后系统就会退出去这是什么原因造成的 之前我打算新建一个xml但是也是获取不到这些东西
[2016-03-30 16:10:19 - ddms] null java.nio.BufferOverflowException at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:200) at com.android.ddmlib.JdwpPacket.movePacket(JdwpPacket.java:235) at com.android.ddmlib.Debugger.sendAndConsume(Debugger.java:347) at com.android.ddmlib.Client.forwardPacketToDebugger(Client.java:630) at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:344) at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263) 我改成单线程以后就是这样的
zhangyikai321 2016-03-30
  • 打赏
  • 举报
回复
引用 楼主 zhangyikai321 的回复:
我在对原有系统的xml进行布局但是布局以后我发现系统没办法调用xml文件了但是没修改之前是可以的 这是什么问题 修改后的xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tool11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:background="@drawable/tool11" > <LinearLayout android:layout_width="match_parent" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:orientation="horizontal" > <SeekBar android:id="@+id/seekBar1" android:layout_width="180dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="28dip" android:max="30" > </SeekBar> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:orientation="horizontal" > <imagebutton android:id="@+id/ImageButton01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg_fhzl1" /> <imagebutton android:id="@+id/ImageButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg_lsct1" /> <imagebutton android:id="@+id/ImageButton03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg_sjzx1" /> </LinearLayout> </RelativeLayout> 修改前的xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tool11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:background="@drawable/tool11" > <SeekBar android:id="@+id/seekBar1" android:layout_width="180dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="28dip" android:max="30" > </SeekBar> </RelativeLayout> toolpop1 = this.getLayoutInflater().inflate(R.layout.tool11, null); toolpop1获取的是空的 然后系统就会退出去这是什么原因造成的 之前我打算新建一个xml但是也是获取不到这些东西
03-30 16:04:24.263: E/AndroidRuntime(3791): FATAL EXCEPTION: main 03-30 16:04:24.263: E/AndroidRuntime(3791): Process: com.kaixinbook, PID: 3791 03-30 16:04:24.263: E/AndroidRuntime(3791): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kaixinbook/com.kaixinbook.Read}: java.lang.RuntimeException: Binary XML file line #9: You must supply a layout_height attribute. 03-30 16:04:24.263: E/AndroidRuntime(3791): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2248) 03-30 16:04:24.263: E/AndroidRuntime(3791): at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 03-30 16:04:24.263: E/AndroidRuntime(3791): at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 03-30 16:04:24.263: E/AndroidRuntime(3791): at com.kaixinbook.Read.onCreate(Read.java:341) 03-30 16:04:24.263: E/AndroidRuntime(3791): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1089)
小白在此 2016-03-30
  • 打赏
  • 举报
回复
把错误日志贴出来啊
本指南详细阐述如何利用STM32微控制器作为系统管理总线主设备,与MLX90614非接触式红外测温模块建立数据通信。STM32系列芯片内置多种外设接口,其中系统管理总线作为一种低速率、节能型双线制串行协议,适用于设备监控与传感器信息采集等场景。 MLX90614模块通过红外技术检测目标物体及周边环境温度,其兼容I²C与系统管理总线标准,可广泛应用于智能设备、医疗监护等领域。借助总线通信,能够从该传感器获取高精度的温度数值。 实施连接需按以下环节操作: **一、硬件配置** - 选用支持系统管理总线或I²C接口的STM32评估板(如STM32F103C8T6型号)。 - 将传感器的串行数据线与串行时钟线分别接入微控制器对应的通信引脚。 - 安排外部供电线路并设置保护电路,保障传感器稳定运行。 **二、软件开发环境搭建** - 使用STM32CubeMX工具创建工程,选定对应处理器型号与开发板,在配置界面激活系统管理总线接口,设定时钟频率并分配引脚功能。 - 基于HAL库编写底层驱动:调用库函数初始化总线,配置时序参数包括传输速率、时钟信号保持时间等。 **三、传感器通信规约解析** - 查阅MLX90614技术文档,掌握其设备地址(默认7位地址为0x5A)、指令编码及数据帧结构。通过访问不同存储单元可读取温度信息。 - 依据系统管理总线规范设计读写流程,实现命令发送、数据接收及应答信号处理的相关函数。 **四、温度信息获取流程** - 向传感器特定存储地址(例如0x2D或0x31)发送读取指令。 - 接收返回的16位二进制温度数据,该数据包含整数与小数部分,需按规范转换为摄氏温度值。 **五、异常状态管理** - 在通信函数中加入超时检测、应答失败判断等异常处理机制。 - 在主程序循环中实施定期状态监控,确保系统长期可靠工作。 **六、程序实现参考** - 典型驱动文件包含总线通信功能模块与温度解析函数,可调用HAL库中的主设备发送与接收函数完成数据传输。 完成上述步骤后,即可建立STM32与MLX90614间的稳定通信链路。实际部署时还需综合考虑电源优化、中断响应、数据存储与显示等扩展功能。建议编程时采用模块化设计并添加详尽注释,以提升代码可维护性与可扩展性。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!

80,491

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧