ogaclejapan / SmartTabLayout

A custom ViewPager title strip which gives continuous feedback to the user when scrolling
Apache License 2.0
7.09k stars 1.34k forks source link

Text for selected item and icons for rest #119

Closed vipulyaara closed 8 years ago

vipulyaara commented 8 years ago

Thanks to the flexibility of smartTabLayout, I have experimented with icons and text in tabs successfully. I am using both text and icons and using TabProvider to implement it. But I am not sure how to show text for the tab item when it is seletced and show icons for rest. So basically, I want to set visibility of text to visible only for the item that is selected. (Kind of like Tinder's home tab)

ogaclejapan commented 8 years ago

Hi, @vipulyaara

By creating a CustomLayout, you may be able to control if override the setSelected method.

For example,


public class CustomLayout extends FrameLayout {

  TextView textView;

  @Override
  public void setSelected(boolean isSelected) {
    textView.setVisibility(...);
  }

}

SmartTabLayout calls the View#setSelected method of the selected TabView.

https://github.com/ogaclejapan/SmartTabLayout/blob/master/library/src/main/java/com/ogaclejapan/smarttablayout/SmartTabLayout.java#L627

https://github.com/ogaclejapan/SmartTabLayout/blob/master/library/src/main/java/com/ogaclejapan/smarttablayout/SmartTabLayout.java#L409

Is my understanding correct? I'm sorry I was wrong meaning because never used Tinder

vipulyaara commented 8 years ago

Thanks. Amazing job!