Hi Greg,

wow. Thanks a lot for such detailed information.

I have been trying to do what i described above with View and
Animation, just like you said.

and it seems to work just fine, though currently doesn't look so good
as "ZoomControls" :)

maybe i should use some images in the Views instead of pure text.

Thanks again and it helps a lot~:)

Fu


On Apr 5, 2:26 pm, Greg Krimer <[email protected]> wrote:
> Hi,
>
> A good place to start is to look at the ApiDemos application to see if
> there is anything there close to what you want. The best I found is
> com.example.android.apis.view.Animation2, which uses a ViewFlipper to
> transition from one view to another with various animations. It's not
> exactly what we want, because we actually want to fade in/out a single
> view. But Animation2 does give us the names of the fading animations:
> android.R.anim.fade_in and android.R.anim.fade_out.
>
> You can apply an animation to any view (and its children) by calling
> startAnimation(). So ...
>
>     myView.startAnimation(AnimationUtils.loadAnimation(mContext,
> android.R.anim.fade_in))
>
> ... would fade in the view and ...
>
>     myView.startAnimation(AnimationUtils.loadAnimation(mContext,
> android.R.anim.fade_out))
>
> ... would fade it out.
>
> The trick is that when the animation ends we want to change the
> visibility of the view. If we are fading in then at the end of the
> animation we want to make the view visible. If we are fading out then
> at the end of the animation we want to make the view invisible.
>
> Luckily, views have a onAnimationEnd() method that is called when the
> animation terminates. We can override this method and change the
> visibility of the view as appropriate. Because we want to override a
> method we will need a custom view. Our custom view might have methods
> like this:
>
>         public void fadeIn() {
>                 startAnimation(AnimationUtils.loadAnimation(mContext,
> android.R.anim.fade_in));
>                 mVisibilityOnAnimationEnd = VISIBLE;
>         }
>
>         public void fadeOut() {
>                 startAnimation(AnimationUtils.loadAnimation(mContext,
> android.R.anim.fade_out));
>                 mVisibilityOnAnimationEnd = INVISIBLE;
>         }
>
>         @Override public void onAnimationEnd() {
>                 super.onAnimationEnd();   // make sure to chain up to 
> superclass
> method
>                 setVisibility(mVisibilityOnAnimationEnd);
>         }
>
>         private int mVisibilityOnAnimationEnd;
>
> Anyway, that's the simplest way I can think of doing this. Anyone have
> other ideas?
>
> Now, we still need to figure out what View to extend. Every view
> accepts the onClick event, so we can extend ImageView. But the zoom
> control has two clickable images, so more likely we will need to
> extend a view group such as LinearLayout.
>
> Getting our view to appear now just requires calling fadeIn() and
> getting our view to disappear just requires calling fadeOut(). To get
> the view to disappear after a delay create a Handler and either send
> it a message with a delay or post a runnable with a delay.
>
> Hope that gets you started.
>
> Greg
>
> On Apr 4, 1:48 am, AllSet <[email protected]> wrote:
>
>
>
> > i am trying to make a control which looks like the ZoomControls.
>
> > it is supposed to show up when clicking in a certain area and
> > disappear a few seconds later.
>
> > also it should accept the onClick event.
>
> > but i don't know exactly how to realize such a control.
>
> > could anybody help me?
>
> > thanks in advance!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to