我的应用程序无法运行,因为我的xml文件中存在错误.我的一个LinearLayouts标记为红色,通过悬停我可以看到以下错误消息:
未指定方向,默认为水平.当动态添加子项时,这是常见的错误来源.
未指定方向,默认为水平.当动态添加子项时,这是常见的错误来源.
你可以在下面看到我的代码,我会在下面写下这条消息:
< - 错误消息 - >
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <LinearLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="vertical" > <Button android:id="@+id/btn1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Fragment 1" /> <Button android:id="@+id/btn2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Fragment 2" /> <Button android:id="@+id/btn3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Fragment 3" /> </LinearLayout> <LinearLayout <- error message -> android:id="@+id/myFragment" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="3" /> </LinearLayout>
解决方法
您应该在LinearLayout块中添加android:orientation =“horizontal”,与上面的操作相同.
原文地址:https://www.jb51.cc/android/316420.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。