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但是也是获取不到这些东西
...全文
190 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
  • 打赏
  • 举报
回复
把错误日志贴出来啊

80,350

社区成员

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

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