I have the following android layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainTopLevel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/orbitImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:scaleType="fitStart"
android:src="@drawable/earthorbit"
android:padding="0dp"
android:background="@android:color/white"
/>
<TextView
android:id="@+id/positionDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="40dp"
android:layout_below="@id/orbitImage"
android:text="should appear below image"
/>
</RelativeLayout>
The image scales down quite a bit, but since the aspect ratio is maintained, it only takes up the top half of the screen.
The problem is that the image view itself has the original height, which takes the entire screen and the text never shows up.
(So the original image is about 620 X 430, the scaled image is about 250 X 200, but the image view is about 250 X 430)
Is there a way to get the size of the image view to exactly match the scaled size of the image?
android:adjustViewBounds—If set to true, the attribute adjusts the bounds of the ImageView control to maintain the aspect ratio of the image displayed through it. android:resizeMode—The resizeMode attribute is used to make a control resizable so we can resize it horizontally, vertically, or around both axes.
How to show the full size image in popup on clicking the image in android. Below is the code that will show the full size image in a dialog box popup without defining layout xml file . int a=v. getId(); intiger "a" will have the value equal to profile_pic if we touched on profile_pic imageview else we will get pro id .
Tap the image you want to adjust. You can adjust the size of an image or rotate it: Resize: Touch and drag the squares along the edges. Rotate: Touch and drag the circle attached to the image.
It looks similar to this problem: Android ImageView size not scaling with source image, to which to the solution was to add android:adjustViewBounds="true"
to the ImageView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With