문제

I am using the ViewPagerIndicator library by Jack Wharton and want to place the TitlePageIndicator next to some other view, which doesn't work. For some reason, the titles of the views are misplaced and don't appear above the thick indicator line.

misplaced text

When I scroll to the right, i.e., to the next page of the ViewPager, INFOS doesn't disappear but stays at the same position:

scrolling

How can I avoid this behaviour? My layout.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:custom="http://schemas.android.com/apk/res-auto"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/head"
            android:orientation="horizontal"
            android:gravity="bottom|center_horizontal">

        <LinearLayout
                android:id="@+id/names"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:background="@drawable/bottom_line_whisky">

            <TextView .../>

            <TextView .../>

        </LinearLayout>


        <com.viewpagerindicator.TitlePageIndicator
                android:id="@+id/titles"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:layout_marginBottom="1dp"/>

    </LinearLayout>

    <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    </android.support.v4.view.ViewPager>


</LinearLayout>
도움이 되었습니까?

해결책

Wrapping the TitlePagerIndicator with another View apparently solves the issue.

<LinearLayout android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal">

    <com.viewpagerindicator.TitlePageIndicator
            android:id="@+id/titles"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"/>
</LinearLayout>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top