private void setupRadioGroup() {
    // Setup the initially checked item
    switch (mTabLayout.getTabMode()) {
      case TabLayout.MODE_SCROLLABLE:
        ((RadioButton) findViewById(R.id.rb_tab_scrollable)).setChecked(true);
        break;
      case TabLayout.MODE_FIXED:
        ((RadioButton) findViewById(R.id.rb_tab_fixed)).setChecked(true);
        break;
    }

    RadioGroup rg = (RadioGroup) findViewById(R.id.radiogroup_tab_mode);
    rg.setOnCheckedChangeListener(
        new RadioGroup.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup radioGroup, int id) {
            switch (id) {
              case R.id.rb_tab_fixed:
                mTabLayout.setTabMode(TabLayout.MODE_FIXED);
                break;
              case R.id.rb_tab_scrollable:
                mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
                break;
            }
          }
        });

    // Setup the initially checked item
    switch (mTabLayout.getTabGravity()) {
      case TabLayout.GRAVITY_CENTER:
        ((RadioButton) findViewById(R.id.rb_tab_g_center)).setChecked(true);
        break;
      case TabLayout.GRAVITY_FILL:
        ((RadioButton) findViewById(R.id.rb_tab_g_fill)).setChecked(true);
        break;
    }

    rg = (RadioGroup) findViewById(R.id.radiogroup_tab_gravity);
    rg.setOnCheckedChangeListener(
        new RadioGroup.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup radioGroup, int id) {
            switch (id) {
              case R.id.rb_tab_g_center:
                mTabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);
                break;
              case R.id.rb_tab_g_fill:
                mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
                break;
            }
          }
        });
  }