I did a tiny optimization, I prefill a list with the children, such that I 
just do 

childrenList.get(index);

instead of

int itemIndex = done.get(index);
int rowIndex = (int)Math.floor(itemIndex / ROWS);                
ViewGroup row = (ViewGroup)imageMask.getChildAt(rowIndex);
View child = row.getChildAt(itemIndex - (rowIndex * ROWS));

But, as expected, this didn't have a noticeable improvement.

Am Montag, 18. März 2013 14:53:18 UTC+1 schrieb user123:
>
> I'm trying to make one of these animations where an image "fades in" with 
> tiles. (Note: I need this to work from Api 8)
>
> To do that, I created a black grid and put it on top of the image and 
> using a handler, make each cell dissapear. 
>
> It works but the animation takes a bit more than 1 second, even when I 
> post to the handler without any delay. This looks laggy and strange. The 
> effect has to be very quick.
>
> I tried many things - using programmatically generated linearlayout with 
> rows instead of grid, using fade out animation, using no animation at all, 
> toggling visibility with View.GONE, or View.INVISIBLE, or just setting the 
> background color to 0x00000000. Nothing helps, I can't make the animation 
> quicker.
>
> I tested in 2.3 smartphone, in 4.2 smartphone and 4.2 tablet, all look the 
> same. Well, in the 4.2 devices, the animation sometimes doesn't show at all 
> - like it was executed already. But when it's visible, it's slow.
>
> Any advice on this? Or do I have to use a completly different approach? Is 
> there a library to do this kind of effects, maybe?
>
> Here is my relevant code:
>
>     List<Integer> done = new ArrayList<Integer>();
>     
>     private Handler handler = new Handler();
>     private Runnable fadeInRunnable = new Runnable() {
>         @Override
>         public void run() {
>             if (!done.isEmpty()) {
> //                int index = (int)(Math.random() * done.size());
>                 int index = 0;
>                 
>                 int itemIndex = done.get(index);
>                 int rowIndex = (int)Math.floor(itemIndex / ROWS);
>                 
>                 ViewGroup row = (ViewGroup)imageMask.getChildAt(rowIndex);
>                 
>                 View child = row.getChildAt(itemIndex - (rowIndex * ROWS));
>                 
> //                
> child.startAnimation(AnimationUtils.loadAnimation(getActivity(), 
> R.anim.fade_out_short));
> //                child.startAnimation(anim);
>                 child.setBackgroundColor(0x00000000);
> //                child.setVisibility(View.INVISIBLE);
>                 
>                 done.remove(index);
>                 
>                 handler.post(this);
> //                handler.postDelayed(this, 1);
>             }
>         }
>     };
>
>
> Thanks in advance,
> Ivan
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to