0
votes

I am getting a bitmap from a server which is wider than it is high eg height = 612, width = 816 and putting it in an ImageView that is: Height = 568 and Width =320. The image that comes from the server appears landscaped in the imageview, that is, it appears on its side. enter image description hereHowever I want to scale it to fit the ImageViews dimensions. I tried a lot of different scale types, fitXY i thought would fix it but it is still the same. Below is my xml:

<ImageView
    android:id="@+id/imageView1"
    android:adjustViewBounds="true"
    android:layout_width="320dp"
    android:layout_height="568dp"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:scaleType="fitXY"
    /> 
1
scale down the bitmapRaghunandan
I also tried this but it was almost unreadableDevC

1 Answers

0
votes

use like this:

in res folder : make value-land folder and thenmake dimen.xml put these height widht value in it

like:

 <dimen name="image_widht">816dp</dimen>`
<dimen name="image_height">612dp</dimen>

in your image view :

<ImageView
    android:id="@+id/imageView1"
    android:adjustViewBounds="true"
    android:layout_width="@dimen/image_widht"
    android:layout_height="@dimen/image_heigh"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:scaleType="fitXY"
    />

also you have make dimension xml in value folder for potrate and put the dimension with same name with differnt value whicjh you want