Я хотел бы знать новый размер моего изображения, когда он установлен в изображении.новый размер изображения в изображенииView
Я попытался это:
System.out.println("Imagesize 1 w:" + imageView.getDrawable().getIntrinsicWidth()+" h "+imageView.getDrawable().getIntrinsicHeight());
System.out.println("Imagesize 2 w:" +loadedImage.getWidth()+ " h " +loadedImage.getHeight());
xml1 из ImageView:
android:layout_width="fill_parent"
android:layout_height="fill_parent"
У меня есть этот результат
Imagesize 1 w:400 h 577
Imagesize 2 w:400 h 577
xml2 из ImageView:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Тот же результат:
Imagesize 1 w:400 h 577
Imagesize 2 w:400 h 577
Очевидно мое изображение не отображается в моем экране с таким же размером в случае xml1 и xml2. Я предполагаю, что когда я getWidth или getHeight, это реальный размер изображения, но мне бы хотелось, чтобы размер изображения отображался на моем экране.
Любые идеи?
Update 1:
Я забыл сказать, что loadedImage является растровым моим образом
Update 2:
XML.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="1dip" >
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/descr_image"
android:layout_alignParentBottom="true" />
<ProgressBar
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Спасибо за ваш ответ, я пытался ваше решение, и у меня есть один и тот же результат w: 536, h: 846 для всех моих разных изображений .. – GermainGum
Каков фактический размер изображения? Возможно, стоит посмотреть на метод setAdjustViewBounds (boolean adjustViewBounds) ImageView. – alistair
У меня есть несколько разных изображений, поэтому различный размер, но пример, который я поставил в этом посте: real size: 400 * 577 – GermainGum