views:

60

answers:

1

I am using a translate animation:

<?xml version="1.0" encoding="utf-8"?>
<set
  xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  <translate
    android:fromXDelta="-75%p"
    android:toXDelta="0%p"
    android:duration="1000" />
</set>

on a basic ImageView. This animation will slide the image out from the left until it reaches the right edge of the screen. I have an OnClickListener set on the ImageView which toggles it from sliding out and in - works great.

Problem: It seems that the ImageView is not actually moving it's coordinates, but it just looks like it's moving. When the ImageView is only partly visible(waiting to be animated out into the screen), if I click on an area where the ImageView would be if it were slid out, the animation starts(OnClickListener is fired off).

I wasn't clicking on the ImageView!

Question: So, components with an animation such as this do not actually move? How can I handle this onClick event, as it would be unexpected for an animation to occur when pressing on the screen where the ImageView is not visible to the user?

A: 

You're right, the components don't really move, only their rendered bitmap buffer. After animating out of the screen, you can use View.setVisibility(View.GONE); to make it really disappear.

If your target is to have a small part of the view still visible to allow the user to slide it back on the screen, you might consider using a SlidingDrawer.

Kevin Gaudin
but if it were to really disappear, the toggling effect i want will no longer be available for the user(visually). they won't know they can click it again. once the animation is complete it will essentially be gone for good!
binnyb
Maybe should you use a SlidingDrawer widget ? (updated my answer)
Kevin Gaudin
I found the `SlidingDrawer` widget to be very limiting as to what you can make it do. seems impossible to change which direction it slides, using a more complex `handle`, positioning the widget where you want, etc
binnyb
Ok I understand what you want to achieve now. So you have to find a way to rearrange your layout so that your ImageView, or maybe another one containing only a part of the Bitmap, appears on the side of the screen...
Kevin Gaudin