2011-11-29 80 views
0

我很新开发android应用程序,所以请耐心等待。如上所述,我正在尝试制作一张左侧图像列表和图像右侧的标题和描述。ListView中的ImageViews不是垂直对齐[Mono for Android]

图像在后台从网上下载,然后在完成后在用户界面中设置。这一切都有效。然而,图像不正确,我简直不明白为什么。我认为它与xml文件中定义的布局有关?我尝试使用android:layout_alignParentLeft="true"android:layout_gravity="left",但那让我无处可去。

然后我不知道如何继续下去,即使用Google搜索的方式我都能想到。对不起,如果这是非常基本的,但我真的很感谢这里的一些帮助。

这里的情况PIC:

http://i.imgur.com/r8G98.png

这是我的布局:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/widget28" 
    android:layout_width="fill_parent" 
    android:layout_height="80px" 
> 
    <ImageView 
    android:id="@+id/imageItem" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_vertical" 
    android:layout_alignParentLeft="true" 
    > 
    </ImageView> 
    <LinearLayout 
    android:id="@+id/linearText" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:layout_marginLeft="10px" 
    android:layout_marginTop="10px" 
     > 
     <TextView 
     android:id="@+id/textTop" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="TextView" 
      > 
     </TextView> 
     <TextView 
     android:id="@+id/textBottom" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="TextView" 
      > 
     </TextView> 
     </LinearLayout> 
</LinearLayout> 

我很欣赏你可以提供任何帮助。

回答

0

这里有两种方法可以实现你的愿望:

1.Fix的ImageView的宽度和高度,使用android:scaleType="fitXY"。这听起来很糟糕,但实际上我所知道的几乎所有的图库应用都以缩略图预览模式使用它。

2.设置android:scaleType="fitStart"。没有承诺这将工作,取决于图像源的宽度和高度的比例。但是如果你所有的图像源都是风景风格(宽度>高度),这种方式应该可以工作。

+0

因为我的所有图像都是风景风格,所以我继续前进并尝试#2。那就是诀窍。谢谢! – ppries