I have a quick question. Im currently using bitmaps that get drawn above a dynamic moving object on screen and when a user clicks them Im using some custom code to open a view with a registered onclick. Instead of using the code we came up with I was wondering if its possible just to replace the bitmap with an imageView.
Will that work? or should I just stick it out and continue to build on the custom class Ive built. After looking at requirements it became apparent to me that an imageview would have all the built in functionality that I would need to do what I want. Or is there a better v开发者_C百科iew class that would work for a dynamically moving view on the screen that moves.
You could use animations for moving views.
example:
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(100);
set.addAnimation(animation);
animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
-1.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(1500);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.25f);
yourView.setLayoutAnimation(controller);
controller.start();
Or in the custom view's onDraw, manipulate the canvas.
精彩评论