Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add icon with text in tab layout

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.36k
    Comment on it

    In the below code example I have created a Tab layout, here I have created two methods, first is add text value and second in declare icons.You can see below example code it clearly describes How to add icon with text in tab layout.

     

    // icon declare
        private int[]tabIcons={
                R.drawable.male,
                R.drawable.female
        };
    
    // set Icon position
    
        private void setupTabIcons() {
            tabLayout.getTabAt(0).setIcon(tabIcons[0]);
            tabLayout.getTabAt(1).setIcon(tabIcons[1]);
    
        }
    
    
      // tab Text declare
        private void setupViewPager(ViewPager viewPager) {
            ViewPagerAdapter adapter = new ViewPagerAdapter(getFragmentManager());
            adapter.addFrag(new MaleTab(), "Male");
            adapter.addFrag(new FemaleTab(), "Female");
    
            viewPager.setAdapter(adapter);
        }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: