Java Code Examples for android.support.design.widget.TabLayout#setTabTextColors()
The following examples show how to use
android.support.design.widget.TabLayout#setTabTextColors() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From RetrofitClient with MIT License | 6 votes |
private void initView() { tlMain = (TabLayout) findViewById(R.id.tl_main); vpMain = (ViewPager) findViewById(R.id.vp_main); List<Fragment> fragmentList = new ArrayList<>(); fragmentList.add(BaseRequestFragment.newInstance()); fragmentList.add(FileUploadFragment.newInstance()); fragmentList.add(FileDownloadFragment.newInstance()); fragmentList.add(MovieDemoFragment.newInstance()); String[] titles = {"基本请求", "文件上传","文件下载","电影Demo"}; MainVpAdapter adapter = new MainVpAdapter(getSupportFragmentManager(), fragmentList, titles); vpMain.setAdapter(adapter); // vpReportIncomeSetting.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tlReportIncomeSetting)); tlMain.setupWithViewPager(vpMain); tlMain.setTabMode(TabLayout.MODE_SCROLLABLE); tlMain.setTabTextColors(getResources().getColor(R.color.white), getResources().getColor(R.color.colorAccent)); tlMain.setSelectedTabIndicatorColor(getResources().getColor(R.color.colorAccent)); }
Example 2
Source File: ProgressChartCard.java From ResearchStack with Apache License 2.0 | 6 votes |
private void initializeViews() { titleTextView = (TextView) findViewById(R.id.view_chart_progress_title); titleTextView.setText(titleText); titleTextView.setTextColor(titleTextColor); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize); titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL)); finishView = (TextView) findViewById(R.id.view_chart_progress_finish); finishView.setText(finishText); finishView.setTextColor(finishTextColor); tabLayout = (TabLayout) findViewById(R.id.view_chart_progress_tabs); tabLayout.setSelectedTabIndicatorColor(tabIndicatorColor); tabLayout.setTabTextColors(tabTextColor, tabSelectedTextColor); chart = (PieChart) findViewById(R.id.view_chart_progress_chart); chart.setDrawSliceText(false); chart.setTouchEnabled(false); chart.setHoleColor(Color.TRANSPARENT); chart.setHoleRadius(95f); chart.getLegend().setEnabled(false); chart.setDescription(""); chart.setCenterTextColor(centerTextColor); chart.setCenterTextSize(centerTextSize); chart.setCenterTextTypeface(Typeface.create(centerTextTypeface, Typeface.NORMAL)); }
Example 3
Source File: ColorPrefUtil.java From ColorPrefUtil with MIT License | 5 votes |
/** * Change icon tint and text colors of NavigationView * * @param backgroundColorId is the color TabLayout's background * @param tabNormalTextColorId is the normal text color * @param tabSelectedTextColorId is the selected tab text color */ public static void changeColorOfTabLayout(@NonNull Context context, @NonNull TabLayout tabLayout, @NonNull Integer backgroundColorId, @NonNull Integer tabNormalTextColorId, @NonNull Integer tabSelectedTextColorId, @NonNull Integer tabSelectedIndicatorColorId){ tabLayout.setBackgroundColor(ContextCompat.getColor(context, backgroundColorId)); tabLayout.setTabTextColors(ContextCompat.getColor(context, tabNormalTextColorId), ContextCompat.getColor(context, tabSelectedTextColorId)); tabLayout.setSelectedTabIndicatorColor(ContextCompat.getColor(context, tabSelectedIndicatorColorId)); }
Example 4
Source File: MainActivity.java From excelPanel with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); pager = (ViewPager) findViewById(R.id.pager); tabLayout = (TabLayout) findViewById(R.id.tab_layout); pager.setAdapter(new ExcelPagerAdapter(getSupportFragmentManager())); tabLayout.setupWithViewPager(pager); tabLayout.setTabTextColors(Color.WHITE,Color.WHITE); }
Example 5
Source File: MainActivity.java From android-news-app with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle(getString(R.string.app_name)); setSupportActionBar(toolbar); // Find the view pager that will allow the user to swipe between fragments ViewPager viewPager = findViewById(R.id.viewpager); // Give the TabLayout the ViewPager TabLayout tabLayout = findViewById(R.id.sliding_tabs); tabLayout.setSelectedTabIndicatorColor(ContextCompat.getColor(this, R.color.colorAccent)); tabLayout.setTabTextColors( ContextCompat.getColor(this, android.R.color.white), ContextCompat.getColor(this, android.R.color.black) ); tabLayout.setupWithViewPager(viewPager); // Create an adapter that knows which fragment should be shown on each page NewsCategoryAdapter adapter = new NewsCategoryAdapter(this, getSupportFragmentManager()); // Set the adapter onto the view pager viewPager.setAdapter(adapter); }
Example 6
Source File: MainActivity.java From Bookster with Apache License 2.0 | 5 votes |
private void initView() { getWindow().setBackgroundDrawable(null); addpage(new AiXiaFragment(), "爱下"); addpage(new ZhiXuanFragment(), "知轩藏书"); addpage(new ZhouDuFragment(), "周读"); addpage(new ShuYuZheFragment(), "书语者"); addpage(new DongManZhiJiaFragment(), "动漫之家"); addpage(new M360DFragment(), "360℃"); addpage(new XiaoShuWuFragment(), "我的小书屋"); addpage(new QiShuFragment(), "奇书"); addpage(new BlahFragment(), "blah"); ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); mPagerAdapter = new PagerAdapter(getSupportFragmentManager(), fragments, titles); viewPager.setAdapter(mPagerAdapter); viewPager.setOffscreenPageLimit(fragments.size()); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { searchView.findFocus(); mPagerAdapter.setTop(tabLayout.getSelectedTabPosition()); } }); if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", false)) { tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.DarkColor)); tabLayout.setTabTextColors(tabLayout.getTabTextColors().getDefaultColor(), getResources().getColor(R.color.DarkColor)); } }
Example 7
Source File: MusicActivity.java From LLApp with Apache License 2.0 | 5 votes |
protected void onInitView() { setTitle("西西音乐"); Help.initSystemBar(this, StaticValue.color);//这个对所有的都适合 Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar1); toolbar.setBackgroundColor(StaticValue.color); setSupportActionBar(toolbar); toolbar.setTitleTextColor(Color.WHITE);//设置ToolBar的titl颜色 toolbar.setNavigationIcon(R.mipmap.abc_ic_ab_back_mtrl_am_alpha);//必须放在setSupportActionBar后才有用,否则没有,设置返回图标 // toolbar.setNavigationOnClickListener(back_btn);//添加按键监听 toolbar.setNavigationOnClickListener(v -> { if (mSearchAutoComplete.isShown()) { try { mSearchAutoComplete.setText(""); Method method = mSearchView.getClass().getDeclaredMethod("onCloseClicked"); method.setAccessible(true); method.invoke(mSearchView); } catch (Exception e) { e.printStackTrace(); } } else { finish(); } }); mSectionsPagerAdapter = new MySectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager)findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); TabLayout tabLayout = (TabLayout)findViewById(R.id.tabs); tabLayout.setTabTextColors(R.color.black,StaticValue.color); tabLayout.setSelectedTabIndicatorColor(StaticValue.color); tabLayout.setupWithViewPager(mViewPager); FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.fab); MDTintUtil.setTint(fab, StaticValue.color); fab.setOnClickListener(view -> Snackbar.make(view,"敬请期待", Snackbar.LENGTH_LONG) .setAction("Action",null).show()); }
Example 8
Source File: MainActivity.java From IdeaTrackerPlus with MIT License | 4 votes |
private void changeTextColor() { //disable search mode for tabLayout disableSearchMode(); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout); tabLayout.setTabTextColors(slightDarken(mTextColor), mTextColor); mToolbar.setTitleTextColor(mTextColor); Drawable myFabSrc = getResources().getDrawable(R.drawable.add); Drawable newColorDrawable = changeDrawableColor(myFabSrc, mTextColor); mFab.setImageDrawable(newColorDrawable); ToolbarColorizeHelper.colorizeToolbar(mToolbar, mTextColor, this); if (rightDrawer != null) { mColorItem3.withIconColor(mTextColor); rightDrawer.updateItem(mColorItem3); } }
Example 9
Source File: TabLayoutHandler.java From NightOwl with Apache License 2.0 | 4 votes |
@Override public void draw(@NonNull View view, @NonNull Object value) { TabLayout tabLayout = (TabLayout) view; ColorStateList csl = (ColorStateList) value; tabLayout.setTabTextColors(csl); }