Viewpager 点指示器不显示

Viewpager dot indicator doesn't display

我正在尝试向我的视图寻呼机添加点指示器,我尝试了不同的类型并且 none 工作,由于某种原因它没有出现在片段中。它不会崩溃...只是不会出现。

我正在尝试使用 this library

查看寻呼机XML 文件:

<LinearLayout android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">

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

    <com.pixelcan.inkpageindicator.InkPageIndicator
        android:id="@+id/indicator"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:dotDiameter="8dp"
        app:dotGap="8dp"
        app:animationDuration="320"
        app:pageIndicatorColor="#a3a0a0"
        app:currentPageIndicatorColor="#000000" />
</android.support.v4.view.ViewPager>
</LinearLayout>

片段activity文件:

public class HighScoreScreenSlide extends FragmentActivity {
    /**
     * The number of pages (wizard steps) to show in this demo.
     */
    private static final int NUM_PAGES = 3;

    /**
     * The pager widget, which handles animation and allows swiping horizontally to access previous
     * and next wizard steps.
     */
    private ViewPager mPager;
    private int countDownInd;
    Bundle bundle;
    /**
     * The pager adapter, which provides the pages to the view pager widget.
     */
    private PagerAdapter mPagerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.high_score_view_pager);
        countDownInd = getIntent().getIntExtra("gameType", 0);
        // Instantiate a ViewPager and a PagerAdapter.
        mPager = (ViewPager) findViewById(R.id.pager);
        mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
        mPager.setAdapter(mPagerAdapter);
        mPager.setCurrentItem(countDownInd);
        InkPageIndicator inkPageIndicator = (InkPageIndicator) findViewById(R.id.indicator);
        inkPageIndicator.setViewPager(mPager);

    }

    @Override
    public void onBackPressed() {
        if (mPager.getCurrentItem() == 0) {
            // If the user is currently looking at the first step, allow the system to handle the
            // Back button. This calls finish() on this activity and pops the back stack.
            super.onBackPressed();
        } else {
            // Otherwise, select the previous step.
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        }
    }

    /**
     * A simple pager adapter that represents 5 ScreenSlidePageFragment objects, in
     * sequence.
     */
    private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {

        public ScreenSlidePagerAdapter( FragmentManager fm) {

            super(fm);
        }

        @Override
        public Fragment getItem(int position) { //use position
            HighScoreFragment fragment = new HighScoreFragment();
            bundle=new Bundle();
            bundle.putInt("gameType",position);
            fragment.setArguments(bundle);
            return fragment;

                        }

        @Override
        public int getCount() {
            return NUM_PAGES;
        }
    }
}

this library没用。

如果需要更多代码来理解我很乐意提供 谢谢!

尝试将 InkPageIndicator 视图不放在 ViewPager 内,而是放在与它相同的水平面上,如 sample 所示。在这种特殊情况下,InkPageIndicatorViewPager 应该是 LinearLayout 的子代。如果您希望指示点位于视图寻呼机的顶部,请考虑将 LinearLayout 替换为 FrameLayout