0

URLからImageViewに画像をロードしています。(RSS フィードから)

問題は、読み込まれた画像の解像度が元の画像よりも低いことです!!

Stackoverflow を検索したところ、「inScaled」オプションを false に設定して画像の再スケーリングを防ぐことが解決策であることがわかりました。しかし、この解決策は私にはうまくいきませんでした。

コードは次のとおりです。

    URL feedImage= new URL(img_link);
    HttpURLConnection conn= (HttpURLConnection)feedImage.openConnection();
    InputStream is = conn.getInputStream();
    BitmapFactory.Options  BFoptions = new BitmapFactory.Options();
    BFoptions.inScaled = false;
    Bitmap img = BitmapFactory.decodeStream(is,null, BFoptions);
    int density = img.getDensity(); Log.e("img", "Image density is " + density);
    int width =img.getWidth(); Log.e("img", "Image width is " + width);
    int height  = img.getHeight(); Log.e("img", "Image height is " + height);

    my_image.setImageBitmap(img);

変数密度、幅、および高さは、元の画像の値よりも低くなっています。

ここに私のレイアウトの一部があります:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">


            <ImageView
                    android:id="@+id/joke_image"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"         
                    android:contentDescription="temp description"/>


            <ScrollView
                    android:id="@+id/SV"
                    android:layout_width="fill_parent"
                    android:layout_height="30dp"
                    android:background="@drawable/background"
                    android:paddingTop="10dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingBottom="50dp">

                    <!-- bla 
                         bla 
                         bla  

                         -->


            </ScrollView>   
</RelativeLayout>

前もって感謝します

4

1 に答える 1

0

最後にそれは解決されました:)

コードやImageViewsとは関係ないように見えました.....

RSS フィードのすべての画像はサムネイルです。これが、アプリでは小さく、Web サイトでは大きく表示される理由です。

したがって、解決策は、各画像のURLの末尾にある「_s.jpg」を「_n.jpg」に置き換えることでした:)

この答えが他の誰かに役立つことを願っています:)

于 2012-07-08T18:25:59.967 に答える