9

我为制作了时间表应用程序,我使用ViewPagerIndicator作为片段。但是现在我遇到了问题,我想让TabPageIndicator居中。像这样: ExampleViewPagerIndicator - 将TabPageIndicator设置为中心

而且我想设置单个标签的宽度和高度。并将该选项卡设置为支持选定/按下状态的绘图。

我还没找到解决这些问题的方法。我尝试了onPageSelectedContextThemeWrapper,但这不起作用。 (也许我没有正确使用它)。

这一切都可能使我还是应该寻找除ViewPagerIndicator之外的其他东西? (另外一个没有ViewPagerIndicator的选项也是可以的)。

图像上的应用程序是Untis Mobile,可以在PlayStore上找到。 我已经问过创作者他们是怎么做的,但他们说这个应用不是开源的。 (但我在他们与TwoDScrollView做源中找到,但我不知道)

编辑:

的造型是固定的vpiTabPageIndicatorStyle。 (在XDA开发者的帮助下!)

当我添加20个项目时,它停留在中间,但仅从项目4到项目17,项目1,2,3,18,19,20不在中间。请参阅:

Wrong

我可以添加3级空的物品(或空的空间),以确保第一项和最后一项是在中间?像这样的事情(从条约资料系统手机应用程序):

Good

(我已经尝试过android:paddingLeftvpiTabPageIndicatorStyle但不工作)

我知道viewPager.setCurrentItem(total/2)将设置TabPageIndicator在中间,但它保持在中间,我无法选择其他日子(我在onPageScrolled中称之为)。所以我想当你滚动选中的一个需要在中间。这可能吗?

回答

6

您正在寻找的小工具类似于android水平轮。在android-spinnerwheel有一个实现,它可以是你需要的。

enter image description here

2

那么你并不需要一个viewpagerindicator。在您的活动中使用Amulya Khare建议的水平滚动视图,并在发生滚动时更换碎片。

你的活动布局可能是这样的:

<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> 

设置一个监听wheelview,当变化发生时,你可以把你的片段中的FrameLayout您的活动。

-1

使用这样的:

TabPagerIndicator tbi; 
    ViewPager pager; 

onCreate()做这样

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

我希望这将制定出适合您。 :D

相关问题