koshur
koshur

Reputation: 134

Android Tabbed Layout with View Pager and Fragments is not scrolling smoothly

I am trying to make an android application where I am using a tabbed layout with fragments as the main page. As you can see, the horizontal scrolling has a weird anomaly. The scrolling is fast from 'DASHBOARD' to 'SYSTEM' fragment and it is normal between the other fragments. The same thing happens with the last two fragments. Talking about the views etc, I know they are a bit complex, I can schedule the tasks later but right now I am moreover concerned about the smooth scrolling part.enter image description here

Upvotes: 0

Views: 226

Answers (2)

koshur
koshur

Reputation: 134

if(tab.getPosition()==0 || tab.getPosition()==1 || tab.getPosition()==2 || tab.getPosition()==3 || tab.getPosition()==4 || tab.getPosition()==5 || tab.getPosition()==6){
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        pageAdapter.notifyDataSetChanged();
                    }
                },300);
            }

This is how I solved it.

Upvotes: 1

Chintan
Chintan

Reputation: 414

@daethm1 As per your explanation , Two operation run same time one of is Change Fragment and other one is Tab change , So You can delay the fragment change operation so tab will view like smooth scroll. Example in below

Handler(Looper.getMainLooper()).postDelayed({
 
   //Fragment change operation here

 }, 300)

Upvotes: 0

Related Questions