Android操作栏+;向下滚动时选项卡消失?
某些应用程序具有操作栏+选项卡,当你向下滚动时,选项卡会收缩,直到只有操作栏可见为止 我有自己的代码: XML:Android操作栏+;向下滚动时选项卡消失?,android,android-studio,android-actionbar,Android,Android Studio,Android Actionbar,某些应用程序具有操作栏+选项卡,当你向下滚动时,选项卡会收缩,直到只有操作栏可见为止 我有自己的代码: XML: 我能做些什么来实现这种行为呢?我试过这个,效果很好 在适配器类中,创建一个上下文对象,将其添加到适配器类的构造函数中 private Context context; public MyAdapter(FragmentManager fm,Context context) { super(fm); this.context = context; } 然后在适
我能做些什么来实现这种行为呢?我试过这个,效果很好 在适配器类中,创建一个上下文对象,将其添加到适配器类的构造函数中
private Context context;
public MyAdapter(FragmentManager fm,Context context) {
super(fm);
this.context = context;
}
然后在适配器类getPageTitle中创建一个函数,并使用上下文返回字符串
public CharSequence getPageTitle(int position) {
switch (position) {
case 0 :
return context.getString(R.string.chat);
case 1:
return context.getString(R.string.status);
case 2:
return context.getString(R.string.call);
}
return super.getPageTitle(position);
}
现在,转到主要活动。设置适配器以查看寻呼机时,请使用此选项
viewPager.setAdapter(new MyAdapter(getSupportFragmentManager(),this));
最后一步是使用ViewPager的功能设置
tabLayout.setupWithViewPager(viewPager);
希望它对你有用。:)
如需进一步查询,您也可以通过Facebook和Instagram与我联系
www.facebook.com/himanshu.dubey.967806
www.instagram.com/_-xplosion\uu/?hl=en显示
style/CategoryTab的代码参考:使用app:layout\u scrollFlags=“scroll | exituntilclopsed”@AbhishekKumar谢谢!这正是我想要的。
tabLayout.setupWithViewPager(viewPager);