SlidingTabLayout to fit the screen

前端 未结 9 1639
南笙
南笙 2020-12-07 18:45

I am using Google\'s SlidingTabLayout. As i only have 3 tabs to be displayed, I am seeing empty space after last tab. Please screenshot below.

9条回答
  •  [愿得一人]
    2020-12-07 19:22

    in SlidingTabLayout.java under the following method, just before the return statement:

    protected TextView createDefaultTabView(Context context)
    

    I added these lines to that method:

    final PagerAdapter adapter = mViewPager.getAdapter();
    LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f / adapter.getCount());
    textView.setLayoutParams(param);
    

    that is very close to the answer marked as the solution for the question, however I did not have to use the window manager.

提交回复
热议问题