0

RelativeLayoutとを含むで構成されるギャラリー アイテムがありImageViewますTextView。(下の私の傑作を見てください)

LayoutProblemを巧みに可視化

アクティビティの開始時に、1 つのギャラリー アイテムが画面のすべてのスペースを占有し、画像が左側で失われ、テキストビュー (青いバナー) が長すぎます。画像の幅に応じて、複数のアイテムを並べて表示したい。

画像はサーバーからロードされた後に置き換えられるため、アクティビティを開始/レイアウトするときに画像の幅が正確にどれくらいになるかわかりません。

RelativeLayout画像が読み込まれてビューに配置された後、画像の幅を画像の幅に合わせたいと思います。

getLayoutParams()ギャラリーの ListAdapter 内のメソッドを既に試しましたが、これは ANR につながり、結果はまったくありません。

私のギャラリーアイテムのレイアウトは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/item_wrap"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/item_margin"
        >

    <ImageView
            android:id="@+id/item_image"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:adjustViewBounds="true"
            />

    <TextView
            android:id="@+id/item_name"
            android:layout_width="fill_parent"
            android:layout_height="@dimen/item_title_height"
            android:layout_alignParentBottom="true"
            android:text="Some longer title so you can see how the text behaves"
            android:singleLine="true"
            android:gravity="left|center_vertical"
            android:paddingLeft="10dip"
            android:background="@drawable/title_gradient_grey"
            />

</RelativeLayout>

画像が挿入された後に再レイアウトする方法はありますか?

4

1 に答える 1

0

サーバーからダウンロードした後に画像のサイズを変更する必要があります。これは、ダウンロードしている画像のサイズがはるかに大きく、ImageView のプロパティを

<ImageView ... android:scaleType="fitXY"これはスケーリングにつながります。

他のオプションは

<ImageView ... android:scaleType="center"スケーリングしたくない場合。

于 2012-10-04T13:09:46.353 に答える