ogaclejapan / SmartTabLayout

A custom ViewPager title strip which gives continuous feedback to the user when scrolling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tabView.getLayoutParams() is null

luyuan11233 opened this issue · comments

if (distributeEvenly) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
lp.width = 0;
lp.weight = 1;
}

  if (internalTabClickListener != null) {
    tabView.setOnClickListener(internalTabClickListener);
  }

  tabStrip.addView(tabView);

when "distributeEvenly" is true,"tabView.getLayoutParams()" get null,the answer is before "tabView.getLayoutParams()",you should set " tabStrip.addView(tabView);"

help

help

我的解决方案,亲测有效:

this is my resolve,work right:

tabLayout.setCustomTabView(new SmartTabLayout.TabProvider() {
            @Override
            public View createTabView(ViewGroup container, int position, PagerAdapter adapter) {
                LinearLayout.LayoutParams lp = new LayoutParams(MATCH_PARENT,MATCH_PARENT);
                tab1View.setLayoutParams(lp);
                return tab1View;
            }
        });

help

i help you. 你是**人吗

@makecloud
是啊,诸葛军师...