java为什么我的线性布局与listview中的父级高度不匹配?
我有以下代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:id="@+id/itemLayoutView"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:paddingLeft="@dimen/list_view_layout_margin"
安卓:paddingRight="@dimen/list_view_layout_margin"
安卓:background="@color/yellow">
<LinearLayout
安卓:id="@+id/itemLinearLayoutView"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:orientation="vertical" >
<TextView
安卓:id="@+id/gameNameView"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textSize="@dimen/game_list_text_size" />
<TextView
安卓:id="@+id/gameCreationDateView"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textColor="@color/gray"
安卓:textSize="@dimen/small_text_size"
安卓:textStyle="italic" />
</LinearLayout>
<LinearLayout
安卓:id="@+id/LinearLayoutView"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:background="@color/red"
安卓:orientation="horizontal" >
<Button
安卓:id="@+id/infoButton"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="@string/info" />
<Button
安卓:id="@+id/deleteButton"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="@string/delete" />
</LinearLayout>
</RelativeLayout>
id为itemLinearLayoutView的LinearLayout是将所有内容包装在listview行中的主布局。我遇到的问题是,第二个线性布局子级不采用id为itemLinearLayoutView的父线性布局的高度。有什么解决办法吗?还是代码有问题
# 1 楼答案
# 2 楼答案
只需更改布局高度以匹配父级。问题会解决的
# 3 楼答案
布局需要嵌套在第一个线性布局中,以获取其参数,并且布局高度的值需要更改。代码如下
# 4 楼答案
# 5 楼答案
你的问题在于:
在线性布局中,需要将其更改为“匹配父对象”,以作为父对象的大小。还有,你说
这两种布局互不相关。父母是你的亲戚,你的两个直系亲属都是这个亲戚的孩子。也许这将帮助你调试你遇到的任何进一步的问题