PagerTabStripe and Icon centering

407 Views Asked by At

I have a little problem with my PageTabStripe. The text is not centered as well as the image is.

Here you can see a image of the problem:

enter image description here

This is how I add the images:

@Override
public CharSequence getPageTitle(int position) {

    SpannableStringBuilder sb;
    ImageSpan span;
    switch (position) {

    case 0:
        myDrawable = getResources().getDrawable(R.drawable.icon_haus);
        sb = new SpannableStringBuilder(" " + "Hauptmenü"); 

        myDrawable.setBounds(0, 0, 70, 70);
        span = new ImageSpan(myDrawable, ImageSpan.ALIGN_BOTTOM);
        sb.setSpan(span, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        return sb;
...

And this is the XML:

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <android.support.v4.view.PagerTabStrip
        android:id="@+id/pts_main"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:textAlignment="center"
        android:background="#FFFFFF"        
        android:textColor="#000000" />

</android.support.v4.view.ViewPager> 

I hope someone could help me. :)

0

There are 0 best solutions below