I have an ImageView
in android. I want to move the image partially inside the screen such that only a part of the image is visible. If I set margin or padding in xml the image shrinks. I used a translate Animation
in onCreate
method. But I see image moving the first time the view is presented. I want the image to be partially visible without the shift being visible. Is there any way of doing this?
Have a look at some of the proposed suggestions for similar questions: ImageView one dimension to fit free space and second evaluate to keep aspect ration. Fit image into ImageView, keep aspect ratio and then resize ImageView to image dimensions? Resizing ImageView to fit to aspect ratio.
You can use the view animation system to perform tweened animation on Views. Tween animation calculates the animation with information such as the start point, end point, size, rotation, and other common aspects of an animation.
in the parent view (like LinearView
) set ClipChildrens=false
, if what you are looking for
check this code, it works for me...
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="-20dp"
android:src="@drawable/ic_launcher" />
</FrameLayout>
How about this.
In your Activity's onCreate:
ImageView yourImage = (ImageView)findViewById(R.id.your_image_control_id);
yourImage.setX(1000);
yourImage.setY(1000);
That way, it is positioned properly at startup. Or you could use an AbsoluteLayout and set the image's x and y coordinates that way. Make sure you arent using fill_parent for either the height or width.
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