【发布时间】:2013-07-21 02:52:30
【问题描述】:
我正在为 Android 编写一个应用程序,但我遇到了下一个问题:
我需要通过 Http 将下载的图像显示到包含 ImageView 和 Text 的列表视图中。两者或它们都包含在 LinearLayout 中:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imagenEvento"
android:layout_width="80dp"
android:layout_height="80dp"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:paddingBottom="2dp"
android:contentDescription="@string/contenidoImagen"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/titulo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17sp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/sitio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/fecha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
我以不同的大小动态加载图像,但是当我加载其中一些图像时,我的 ImageView 的大小受到影响,它不会尊重我的高度和宽度声明。
我尝试确定 MAX 和 MIN 尺寸,我在代码中定义了布局参数,确定了底部填充,调整了位图但没有任何效果。
在下一张图片中,黄色圆圈显示相同的空间,红色圆圈显示 ImageView 和行底部之间的不同空间 http://imageshack.us/photo/my-images/32/csww.jpg/
我错过了什么?
【问题讨论】:
-
不,它没有用,我一直得到相同的结果
-
但是 ImageVIew 保持他的大小,正确的 LinearLayout 包含 TextViews 正在根据行而变化
-
@MarcinGawel ImageView 我认为正在改变大小。 TextViews 会根据行发生变化,没错,但它不应该影响 ImageView 的大小
-
其实不然,ImageSize 还是一样的,但是 ImageSize 和底线之间的差距正在改变,因为整个 LinearLayout 改变了他的大小。将 android:layout_gravity="center" 放到 ImageView 中,它将位于中心。看看这个link
-
@MarcinGawel 你是对的,LinearLayout 会根据行而变化
标签: android image imageview image-size