0
我從url加載ImageView中的圖片。 (來自RSS提要)從url中加載圖片的分辨率問題
問題是加載的圖像的分辨率低於原始圖像!
我搜索了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>
在此先感謝