1

Androidアプリケーションでインターネットからダウンロードしている画像があります。この画像をサイズ変更/拡大縮小したくありません。とにかく、画像の拡大縮小を止めることができますか?

ImageView の XML エントリは次のとおりです。

<ImageView 
   android:id="@+id/conditionImage"
   android:scaleType="center"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_below="@id/textMain"
   android:contentDescription="@string/noaaLogoDescription" />

画像ビューに表示するための私のコードは次のとおりです。

BitmapFactory.Options bmpOptions = new Options();
bmpOptions.inScaled = false;
URL url = new URL("URLPATHTOIMAGE");
ImageView conditionImageView = (ImageView)findViewById(R.id.conditionImage);
InputStream content = (InputStream)url.getContent();
conditionImage = BitmapFactory.decodeStream(content, null, bmpOptions);

conditionImageView.setImageBitmap(conditionImage);

ImageView XML 要素の scaleType を、matrix、center、および centerInside を使用するように変更しようとしました。私の最後の試みは、上記のコードを使用して inScale を false に設定することでした。他のアイデアはありますか?

奇妙な部分は、これがエミュレーターで起こっていないことです。

4

5 に答える 5

0

Adnan は、画像ビューに固定幅と高さを与え、scaleType=centerImage を削除する例を使用して問題を修正しました。

于 2013-05-20T19:59:34.233 に答える
0

イメージビューをハードコーディングすることでこの問題を解決しheight(事前に知っているように)、次のように設定しscaleTypeましたcropCenter

より明確にするために、以下のコードを参照してください。

 <ImageView
            android:id="@+id/iv"
            android:layout_width="match_parent"
            android:layout_height="75dp"
            android:scaleType="centerCrop" />
于 2014-02-17T09:34:36.073 に答える
0

すべての画像を単純な「描画可能」フォルダーに入れましたか。hdpi、mdpiなどを拡張せずに意味します。

于 2013-04-29T19:52:03.170 に答える
0

お試しセット

android:layout_width="wrap_content"
android:adjustViewBounds="true"

編集:

理由はわかりませんが、変更します

conditionImageView.setBackgroundDrawable(getResources().getDrawable(R.id.conditionImage));

conditionImageView.setImageDrawable(getResources().getDrawable(R.id.conditionImage));

私の問題を解決します。

于 2013-04-29T15:57:40.263 に答える