Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to change the width of TabPageIndicator (by Jake Wharton)?

I am using Jake Wharton's viewpager indicator and I would like to chage the width of it to a specific value. The common xml file as it can be found in the sample is:

<?xml version="1.0" encoding="UTF-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:background="@drawable/background" >

        <com.viewpagerindicator.TabPageIndicator
            android:id="@+id/indicator"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
       />

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

    </LinearLayout>

The width of the TabPageIndicator is fill_parent now, when I change it to a specific value, the whole things starts to behave weird and not well. I want to put an image in the same row where the TabPageindicator is located, but I do not want that to be the part of it. Is this possible?

like image 256
Jani Bela Avatar asked Dec 01 '25 00:12

Jani Bela


1 Answers

Why don't you put it inside a LinearLayout with padding?

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp" 
        android:paddingRight="10dp">

       <com.viewpagerindicator.TabPageIndicator
            android:id="@+id/indicator"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
       />
    </LinearLayout>
like image 102
erdomester Avatar answered Dec 02 '25 15:12

erdomester



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!