سؤال

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.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top