ListView 中的 ImageView 未垂直对齐 [Mono for Android]

发布于 2024-12-19 04:44:05 字数 1743 浏览 5 评论 0原文

我对开发 Android 应用程序非常陌生,所以请耐心等待。

话虽如此,我正在尝试制作一个列表,其中左侧有图像,图像右侧有标题和描述。

图像在后台从网络下载,然后在完成后设置在 UI 中。这一切都有效。然而,图像没有正确对齐,我根本不明白为什么。我认为这与 xml 文件中定义的布局有关?我尝试使用 android:layout_alignParentLeft="true"android:layout_gravity="left" 但这对我毫无帮助。

然后我不知道如何继续,即使在谷歌搜索了我能想到的所有方法之后。如果这是非常基本的,我很抱歉,但我真的很感激这里的一些帮助。

这是情况的图片:

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>

我感谢您提供的任何帮助。

I'm very new to developing apps to android, so bear with me.

Having said that, I'm trying to make a list with a image to the left and a title and description to the right of the image.

The image is downloaded from the web in the background and then set in the UI as they complete. This all works. However, the images are not aligned properly and I simply cannot understand why. I'm thinking it has something to do with the layout defined in the xml file? I tried using android:layout_alignParentLeft="true" and android:layout_gravity="left" but that got me nowhere.

Then I didn't know how to proceed, even after googling every way I could think of. I'm sorry if this is very basic, but I would really appreciate some help here.

Here's a pic of the situation:

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

And here's my layout:

<?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>

I appreciate any help you can offer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱你不解释 2024-12-26 04:44:05

有两种方法可以实现您想要的效果:

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

2.设置android:scaleType="fitStart"。不保证这会起作用,取决于图像源的宽度和高度的比率。但如果您的所有图像源都是横向样式(宽度>高度),那么这种方式应该可行。

There're two ways to achieve what you desire:

1.Fix the ImageView width and height and use android:scaleType="fitXY". This sounds bad, but actually almost gallery apps I know use it in the thumbnail preview mode.

2.Set android:scaleType="fitStart". No promise this will work, depends on the ratio of width and height of the image source. But if all your image source are landscape style (width > height), this way should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文