【发布时间】:2013-12-01 21:32:14
【问题描述】:
我正在努力解决新手问题。
我有一个这样定义的布局:(它用作列表视图项)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:orientation="horizontal" >
<ImageView
android:id="@+id/articleSmallImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:adjustViewBounds="true"
android:scaleType="fitStart" />
<LinearLayout
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="@+id/newsIntroText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="TextView"
android:textColor="@color/black" />
</LinearLayout>
</LinearLayout>
我想要实现的是: 根据最高子级调整大小的父级布局高度。在这种情况下,如果 TextView 高于 ImageView,则 ImageView 纵横比应该保持不变,最大宽度可能,如果 ImageView i 高于 TextView,那么宽度应该是最大的,并且父级应该具有 ImageView 的高度。
这实际上是我的应用程序的屏幕截图,在 JB 4.3 上运行。看起来和预期的一样。但在 ICS 4.0.3、4.0.4 上看起来像这样。
我看不出 ImageVIew 没有填充该空白空间的任何原因。
帮助..
【问题讨论】:
-
当您在水平线性布局中使用
weight时,您始终将width设置为0dp -
我设置了 0dp 宽度值,但 ICS 没有变化
标签: android android-layout imageview aspect-ratio