【发布时间】:2012-12-24 02:56:46
【问题描述】:
我创建了一个自定义视图,并将其放在 LinearLayout 上。
问题是我不能完全填满layout的高度,自定义View的大小总是平方,width=height。
这是我的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:layout_weight="0">
<it.inav.graphics.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"/>
</LinearLayout>
它似乎工作的唯一方法是使用RelativeLayout并使用两者“拉伸”视图
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
但是,如果我尝试获取尺寸高度,它会返回与之前相同的长度。
【问题讨论】:
-
使用 android:layout_height="fill_parent" 尽管使用 android:layout_height="match_parent"