本文整理匯總了Java中android.widget.LinearLayout.setDividerDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java LinearLayout.setDividerDrawable方法的具體用法?Java LinearLayout.setDividerDrawable怎麽用?Java LinearLayout.setDividerDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.setDividerDrawable方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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);
}
示例3: setLinearLayoutDividerDrawable
import android.widget.LinearLayout; //導入方法依賴的package包/類
@Override
public void setLinearLayoutDividerDrawable(LinearLayout l, Drawable d) {
l.setDividerDrawable(d);
super.setLinearLayoutDividerDrawable(l, d);
}
示例4: 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);
}
}