Tab icon and text both using android design support library

前端 未结 2 373
长发绾君心
长发绾君心 2020-12-06 18:31

]1]1i used android design support tablayout and i got both icon and text on tab .. i used a customtabview to align icon and text vertically..And i want to change the color o

2条回答
  •  情深已故
    2020-12-06 19:02

    Instead of customizing the TabLayout as specified by @Abhilash answer just add a line i.e. tabOne.setSelected(true); in below code

    TextView tabOne = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
    tabOne.setText("ONE");
    tabOne.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.image1, 0, 0);
    tabOne.setSelected(true);  //This will make your tab by default selected
    tabLayout.getTabAt(0).setCustomView(tabOne);
    

提交回复
热议问题