这个简单的android布局哪里出错了?

LOVE_GG 2016-03-15 12:52:32
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@string/topback">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="2"
/>

</LinearLayout>
</LinearLayout>
...全文
260 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
怀君 2016-03-15
  • 打赏
  • 举报
回复
请看三楼。。。。
BlankRen 2016-03-15
  • 打赏
  • 举报
回复
缺少方向属性
画虎烂 2016-03-15
  • 打赏
  • 举报
回复
楼上说的缺少方向属性,如果LinearLaout的child view 只有一个的话是不用指定的,超过两个才必须指定。 应该是3楼说的
qq_26763799 2016-03-15
  • 打赏
  • 举报
回复
呵呵,里层的两个线性布局全没有方向属性,能不报错?包就包了,没什么太大问题,超过7层内嵌才会导致绘制失败,但是线性布局缺少方向属性是不行的
哎,真难 2016-03-15
  • 打赏
  • 举报
回复
应该是楼上那句话
wei220000 2016-03-15
  • 打赏
  • 举报
回复
android:background="@string/topback" 因为这句,background只能是drawable或者color
lliang2 2016-03-15
  • 打赏
  • 举报
回复
楼上说的没错。另外,遇到什么问题了呢?没写。
haha_321 2016-03-15
  • 打赏
  • 举报
回复
1,为什么每个都用linearlayout包一层呢,没必要 2,你可以设置子view的weight 不要都Match_parent

80,349

社区成员

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

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