我有一个简单的布局,但遇到了 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 一样填充其父对象。非常感谢。
最佳答案
我最近才遇到同样的现象。在查看 Android 源代码并将 View 子类化(例如查看 FrameLayout
将传递给其子项的值)之后,很明显这是一个错误。
完整口味请看这里description和 workaround .
元注释:感谢 StackOverflow 审阅者投票赞成将我的原始答案转换为评论,然后反对将此问题标记为重复。现在这就是你得到的。 ;)
关于android - Jelly Bean 和 Froyo 的 ImageView match_parent 不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16103950/