【发布时间】:2013-04-19 20:25:56
【问题描述】:
我有一个简单的布局,但遇到了 Jelly Bean 和 Froyo 之间的差异。在 Jelly Bean 上,我有 ImageView 匹配其父级 (FrameLayout) 的高度。但在 Froyo 上却不是。请看一下布局结构:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@+id/fl"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/profile_data_background_im"
android:scaleType="fitXY"/>
<LinearLayout
android:id="@+id/ll"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test text"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test text"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test text"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test text"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
所以我在 Jelly Bean 上拥有的东西(正如预期的那样):
这是我在 Froyo 上的内容:
请告知如何让ImageView 填充其父级,就像它用于 Jelly Bean 一样。非常感谢。
【问题讨论】:
-
首先,您的屏幕截图是 Eclipse 预览的,这并不是特别相关。使用模拟器或设备进行测试。其次,当你运行 Hierarchy View 来查看你的
ImageView的大小时,你学到了什么? -
这是一个错误; see here, also for a workaround
-
马克,我已经在真实设备上进行了测试,我刚刚从 IDE 截屏。我没有检查层次结构视图,我会这样做。
-
为什么还有 FrameLayout?你已经有一个 LinearLayout...
-
@WarrenFaith 这只是更复杂布局的一部分,我需要它。
标签: android android-4.2-jelly-bean android-2.2-froyo