2 Answers

0
votes

Just put imageviews into your tab layouts. For example, instead of using their Tab1.xml, you could use:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">


 <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/yourIconImage" />

</RelativeLayout>
0
votes

I change this function in ViewPagerAdapter.java and add my icon:

@Override
 public CharSequence getPageTitle(int position) {
        Drawable drawable = getContext().getResources().getDrawable(icons[position]);
        drawable.setBounds(0,0,48,48);
        ImageSpan imageSpan = new ImageSpan(drawable);
        SpannableString spannableString = new SpannableString(" ");
        spannableString.setSpan(imageSpan, 0,spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return spannableString;
    }