本文整理汇总了Java中android.widget.LinearLayout.setShowDividers方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.setShowDividers方法的具体用法?Java LinearLayout.setShowDividers怎么用?Java LinearLayout.setShowDividers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.setShowDividers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showBody
import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
protected void showBody() {
super.showBody();
viewPagerData.addAll(bindFragment());
titleData.addAll(bindTitleValue());
multiTypeAdapter = new MultiTypeAdapter(getChildFragmentManager(), viewPagerData);
mViewPager.setOffscreenPageLimit(builder.getScreenPageLimit());
mViewPager.setAdapter(multiTypeAdapter);
commonNavigator.setAdapter(navigatorAdapter);
commonNavigator.setAdjustMode(builder.isAdjustMode());
magicIndicator.setNavigator(commonNavigator);
LinearLayout titleContainer = commonNavigator.getTitleContainer();
titleContainer.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
titleContainer.setDividerDrawable(new ColorDrawable() {
@Override
public int getIntrinsicWidth() {
return UIUtil.dip2px(mContext, builder.getIntrinsicWidth());
}
});
ViewPagerHelper.bind(magicIndicator, mViewPager);
}
示例2: onCreate
import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tab_layout);
mTabLayout = (TabLayout) findViewById(R.id.tabLayout);
// 手动创建Tab
// for (int i = 0; i < title.length; i++) {
// TabLayout.Tab tab = mTabLayout.newTab();
// tab.setText(title[i]);
//// tab.setIcon(R.mipmap.ic_launcher);//icon会显示在文字上面
// mTabLayout.addTab(tab);
// }
// TabLayout与ViewPager结合使用
mViewPager = (ViewPager) findViewById(R.id.viewPager);
MyViewPagerAdapter adapter = new MyViewPagerAdapter(getSupportFragmentManager());
mViewPager.setAdapter(adapter);
// // 适配器必须重写getPageTitle()方法
// mTabLayout.setTabsFromPagerAdapter(adapter);
// // 监听TabLayout的标签选择,当标签选中时ViewPager切换
// mTabLayout.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
// // 监听ViewPager的页面切换,当页面切换时TabLayout的标签跟着切换
// mViewPager.setOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
// 关联TabLayout与ViewPager,且适配器必须重写getPageTitle()方法
mTabLayout.setupWithViewPager(mViewPager);
mLinearLayout = (LinearLayout) mTabLayout.getChildAt(0);
// 在所有子控件的中间显示分割线(还可能只显示顶部、尾部和不显示分割线)
mLinearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
// 设置分割线的距离本身(LinearLayout)的内间距
mLinearLayout.setDividerPadding(50);
// 设置分割线的样式
mLinearLayout.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.divider_vertical));
mLinearLayout.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));
// 为TabLayout设置不同状态下的字体大小(并不能成功)
// for (int i = 0; i < mTabLayout.getTabCount(); i++) {
// ((TextView) ((LinearLayout) mLinearLayout.getChildAt(i)).getChildAt(1)).setTextSize(10);
//// ((TextView) ((LinearLayout) ((LinearLayout) mTabLayout.getChildAt(0)).getChildAt(i)).getChildAt(0)).setTextSize(12);
// }
// ((TextView) ((LinearLayout) mLinearLayout.getChildAt(mTabLayout.getSelectedTabPosition())).getChildAt(1)).setTextSize(30);
//
// mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
// @Override
// public void onTabSelected(TabLayout.Tab tab) {
// ((TextView) ((LinearLayout) mLinearLayout.getChildAt(tab.getPosition())).getChildAt(1)).setTextSize(30);
// }
//
// @Override
// public void onTabUnselected(TabLayout.Tab tab) {
// ((TextView) ((LinearLayout) mLinearLayout.getChildAt(tab.getPosition())).getChildAt(1)).setTextSize(10);
// }
//
// @Override
// public void onTabReselected(TabLayout.Tab tab) {
//
// }
// });
// 自定义指示器(Indicator)的“长度”的两种方法
// 方法一:反射
// setIndicator(mTabLayout,10,10);
// 方法二:查找子控件
int left = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, Resources.getSystem().getDisplayMetrics());
int right = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, Resources.getSystem().getDisplayMetrics());
for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
View tabView = mLinearLayout.getChildAt(0);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
params.leftMargin = left;
params.rightMargin = right;
tabView.setLayoutParams(params);
}
}
示例3: setCommonTabDivider
import android.widget.LinearLayout; //导入方法依赖的package包/类
public static void setCommonTabDivider(CommonTabLayout tabLayout, @ColorInt int color, int showDividers, int padding) {
LinearLayout linearLayout = (LinearLayout) tabLayout.getChildAt(0);
linearLayout.setDividerPadding(padding);
RectShape rectShape = new RectShape();
float density = tabLayout.getResources().getDisplayMetrics().density;
ShapeDrawable shapeDrawable = new ShapeDrawable(rectShape);
shapeDrawable.setIntrinsicWidth((int) density);
shapeDrawable.setIntrinsicHeight((int) density);
shapeDrawable.getPaint().setColor(color);
shapeDrawable.getPaint().setStyle(Paint.Style.STROKE);
linearLayout.setDividerDrawable(shapeDrawable);
linearLayout.setShowDividers(showDividers);
}