import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initVerticalView(Context context) {
removeAllViews();
setOrientation(HORIZONTAL);
tabGroup = new LinearLayout(context);
tabGroup.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
tabGroup.setOrientation(VERTICAL);
tabGroup.setWeightSum(tabCount);
addView(tabGroup);
TabView tab = addTab(tabTextHint, true);
tabGroup.addView(tab);
tabList = new ArrayList<>();
tabList.add(tab);
for (int i = 1; i < tabCount; i++) {
TabView nullTab = addTab("", false);
tabList.add(nullTab);
tabGroup.addView(nullTab);
nullTab.setIndex(i);
}
indicatorView = new IndicatorView(context, tabCount);
indicatorView.setBgColor(indicatorColor);
indicatorView.setTabOrientation(VERTICAL);
indicatorView.setLayoutParams(new LayoutParams(6, ViewGroup.LayoutParams.MATCH_PARENT));
addView(indicatorView);
divisionLine = new View(context);
divisionLine.setLayoutParams(new LayoutParams(
2, LayoutParams.MATCH_PARENT));
divisionLine.setBackgroundColor(context.getResources().getColor(R.color.gray_line));
addView(divisionLine);
recyclerView = new RecyclerView(context);
recyclerView.setLayoutManager(manager);
if (manager instanceof GridLayoutManager){
recyclerView.addItemDecoration(new SpaceItemDecoration(space));
}
LayoutParams layoutParams=new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
layoutParams.setMargins(10,10,10,0);
recyclerView.setLayoutParams(layoutParams);
addView(recyclerView);
}