ViewPagerIndicator - Set the TabPageIndicator to the center

前端 未结 3 2176
轻奢々
轻奢々 2021-02-14 19:37

I make an timetable application for android and I\'m using ViewPagerIndicator as fragment. But now I\'ve a problem, I want to get the TabPageIndicator to the center. Like this:

相关标签:
3条回答
  • 2021-02-14 19:46

    Use it like this :

    TabPagerIndicator tbi;
       ViewPager pager;
    

    in onCreate() do like this

    tbi=(TabPagerIndicator)findViewById(R.id.something);
       tbi.setViewPager(pager);
    

    I hope this will work out for you. :D

    0 讨论(0)
  • 2021-02-14 19:52

    Then you don't need an viewpagerindicator. Use a horizontal scroll view as Amulya Khare suggested in your activity and replace fragments when scrolling occurs.

    Your activity layout could be like :

    <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
    
            <SomeWheelView 
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                />
            <SomeStaticIndicatorView 
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                />
            <FrameLayout 
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                />
    </LinearLayout>
    

    Set a listener to wheelview and when change occurs you can put your fragments in framelayout in your activity.

    0 讨论(0)
  • 2021-02-14 19:55

    The widget you are looking for is similar to the android horizontal wheel. There is an implementation at android-spinnerwheel which can be what you need.

    enter image description here

    0 讨论(0)
提交回复
热议问题