I was also interested doing same as yours, Finally I did it for you.
Import 'SlidingTabsBasic' demo from android-sdk sample or download it from google android samples from Here.
1.create custom_tab.xml with only a TextView
2.In 'SlidingTabsBasicFragment.class' do below changes:
-add this code in onViewCreated()
mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
mSlidingTabLayout.setCustomTabView(R.layout.custom_tab, 0);
mSlidingTabLayout.setViewPager(mViewPager);
-in SamplePagerAdapter class, replace this function code
public CharSequence getPageTitle(int position)
{
//return "Item " + (position + 1);
Drawable image = getActivity().getResources().getDrawable(imageResId[position]);
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
SpannableString sb = new SpannableString(" ");
ImageSpan imageSpan = new ImageSpan(image, ImageSpan.ALIGN_BOTTOM);
sb.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return sb;
}
If you have done it properly, You will get something like this:
Hope this will help!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…