zoltish
zoltish

Reputation: 2312

Fragment stutters first time it is shown

I have an activity with 4 fragments. On start theyre all hidden except for one which works perfectly fine.

The problem however is that the first time Im doing .show() on one of them the GUI stutters noticably. This only happens the first time it is shown, after that it runs superfast when interchanging between the fragments.

I suspect that the Listview is causing it but Im not sure why. Drawing an item takes 25 ms on average which should be smooth. Views are flat, i.e. no deep hierarchy, the viewholder pattern is used, and scrolling through the list is supersmooth.

Any ideas?

Upvotes: 1

Views: 887

Answers (1)

zoltish
zoltish

Reputation: 2312

So for anyone else stumbling in here looking for the answer to this. Ive solved it and it was as simple as the navigation drawer not working well with the fragment transaction.

Only thing I had to do was to commit the fragment transaction straight after the navigation drawer was hidden.

//Setup fragment transaction , animations , which fragment to show etc.

new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            transaction.commit();

        }
    }, 140);

Upvotes: 2

Related Questions