1

I'm using a SlidingTabLayout in my android application by referring this link http://www.exoguru.com/android/material-design/navigation/android-sliding-tabs-with-material-design.html

And my requirement is like the below image which i have post.

I am not able to tag SlidingTabLayout as my reputation does not fullfil the requirement.

enter image description here

As I am new to this whole setup, I'd appreciate if you'd post proper code with an explaination.

Limon Monte
  • 52,539
  • 45
  • 182
  • 213
ShutterSoul
  • 2,551
  • 3
  • 23
  • 28
  • for sliding tab layout you can follow my answer here http://stackoverflow.com/questions/32925636/tabmode-scrollable-not-working/32926361#32926361 – Awadesh Oct 28 '15 at 09:46
  • @Awadesh my focus is to design the tabs as i have posted.How to put looks exactly like the above image in tabs. – ShutterSoul Oct 28 '15 at 09:50
  • Alternatively, you may consider to use this library : https://github.com/astuetz/PagerSlidingTabStrip – Oğuzhan Döngül Oct 28 '15 at 12:29

1 Answers1

0

In order to inflate the tabs with custom view , in file SlidingTablayout.java there is a method

 public void setCustomTabView(int layoutResId, int textViewId) {
    mTabViewLayoutId = layoutResId;
    mTabViewTextViewId = textViewId;
}

Using this method you can inflate your tabs view. For more details you can follow this also

Android SlidingTabLayout with icons

In order to set different custom views in different tabs you can modify the method populateTabStrip() like this

public void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;

    tabView =     LayoutInflater.from(getContext()).inflate(R.layout.tab_layout, mTabStrip,false);

        ImageView iconImageView = (ImageView)   tabView.findViewById(R.id.tab_layout_icon);
          iconImageView.setImageDrawable(getContext().getResources().getDrawable(getIconResourceArray()[i]));

        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}
Community
  • 1
  • 1
Awadesh
  • 3,530
  • 2
  • 20
  • 32
  • I have tried as above you mentioned. I have 5 no. of tabs then how to handle those in setCustomTabView()? I am not able to do this. – ShutterSoul Oct 28 '15 at 12:09
  • @PRB i have updated my answer, please go in detail of the given link atleast for once, you will find the solution for sure :) – Awadesh Oct 28 '15 at 12:25
  • @Awadesh-- I have one query.. is it possible to customize TabLayout? Not SlidingTabLayout. – ShutterSoul Oct 28 '15 at 13:04
  • @PRB yes you can. So SlidingTabLayout is not working , If you have any doubt please ask :) – Awadesh Oct 28 '15 at 13:13
  • no not yet. :(.... I am not able to set icons for different tabs. where to set the IconResourceArray() and in populateTabStrip() I am getting that.Like this... iconImageView.setImageDrawable(getContext().getResources().getDrawable(getIconResourceArray()[i])); – ShutterSoul Oct 28 '15 at 17:09
  • okk please see this answer , there is everything http://stackoverflow.com/search?q=user:1772823+[android-tabstrip], If you have any doubt please ask – Awadesh Oct 28 '15 at 17:33
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/93613/discussion-between-awadesh-and-prb). – Awadesh Oct 28 '15 at 17:37