ogaclejapan / SmartTabLayout

A custom ViewPager title strip which gives continuous feedback to the user when scrolling
Apache License 2.0
7.09k stars 1.34k forks source link

tabView.getLayoutParams() is null #296

Closed luyuan11233 closed 4 years ago

luyuan11233 commented 4 years ago

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);"

luyuan11233 commented 4 years ago

help

luyuan11233 commented 4 years ago

help

makecloud commented 4 years ago

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

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;
            }
        });
makecloud commented 4 years ago

help

i help you. 你是中国人吗

luyuan11233 commented 4 years ago

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