2

I have created a tab view with swipe using "android.support.v4.view.ViewPager" and "android.support.v4.view.PagerTitleStrip". now i need to display a Button or TextView on top of the Title Strip. Even if i add the textview above the title strip its not getting shown. My xml file is given below.

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

<TextView
            android:id="@+id/label"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello"/>  

<android.support.v4.view.PagerTitleStrip  
android:id="@+id/pager_title_strip"  
android:layout_width="match_parent"  
android:layout_height="wrap_content"  
android:layout_gravity="top"  
android:background="#33b5e5"  
android:paddingBottom="4dp"  
android:paddingTop="4dp"  
android:textColor="#fff" />  

</android.support.v4.view.ViewPager> 
Vignesh
  • 2,295
  • 7
  • 33
  • 41

1 Answers1

3

Why do you try to put TextView inside ViewPager? Maybe my code will be helpful for you:

    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:text="Hello" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignBottom="true"
        android:layout_below="@id/label"
        android:background="@drawable/home_background11"
        tools:context=".MainActivity" >

        <android.support.v4.view.PagerTitleStrip
            android:id="@+id/pager_title_strip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:background="#33b5e5"
            android:paddingBottom="4dp"
            android:paddingTop="4dp"
            android:textColor="#fff" />
    </android.support.v4.view.ViewPager>

</RelativeLayout>
Igor Tyulkanov
  • 5,487
  • 2
  • 32
  • 49