SlidingTabLayout to fit the screen

前端 未结 9 1674
南笙
南笙 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:11

    Changing the SlidingTabLayout.java file may help. However, the solution may not seem very much generic. In the SlidingTabLayout.java file, search for the method

    protected TextView createDefaultTabView(Context context)
    

    Underneath the TextView 'set' methods, type in the following code.

    textView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
    

    Each tab strip is merely a customized LinearLayout.

提交回复
热议问题