首页

源码搜藏网

首页 > 安卓源码 > 控件分类 > 视图切换Transition >

Android交互式指示到ViewPager的不同页面之间进行切换

创建时间:2016-08-18 17:18  

Android交互式指示到ViewPager的不同页面之间进行切换
Android交互式指示到ViewPager的不同页面之间进行切换
暂无演示 立即下载

Android的PagerSlidingTabStrip(默认材料设计)

互动寻呼指示窗口小部件,可以兼容ViewPager从Android支持库。

PagerSlidingTabStrip样品材料 ------ PagerSlidingTabStrip样品材料

用法

对于这个项目的执行工作看到了sample/文件夹。

1.Include在以下依赖build.gradle文件。

    编译 com.jpardogo.materialtabstrip:库:1.1.0 

或库添加为一个Android项目我试图发送一个拉请求,但看起来像原来的开发商不维护它了。

2.Include的PagerSlidingTabStrip在布局小部件。这通常应放在上面ViewPager它代表。

    < com .astuetz.PagerSlidingTabStrip
         android : id = " @+id/tabs "
         android : layout_width = " match_parent "
         android : layout_height = " ?attr/actionBarSize "
         android : background = " ?attr/colorPrimary " />

3.In你的onCreate方法(或onCreateView一个片段),绑定控件到ViewPager

  //初始化ViewPager并设置一个适配器
  ViewPager寻呼机=ViewPager)findViewById(ř  ID 传呼机);
  寻呼机 setAdapter( TestAdapter(getSupportFragmentManager()));

  //绑定选项卡到ViewPager 
  PagerSlidingTabStrip标签=PagerSlidingTabStrip)findViewById(ř  ID 标签);
  标签 setViewPager(寻呼机);

这就是所有你需要做的,但如果你想用自己的选项卡,然后....

4.如果您的适配器实现该接口CustomTabProvider可以粘贴您的自定义选项卡视图/秒。

 - In case the the view returned contains the id `R.id.psts_tab_title`, this view should be a `TextView`  and
 will be used to placed the title and set the view state (pressed/selected/default).

 - If you don't want the library manage your TextView title for the tab, use a different id than `R.id.psts_tab_title` in your tab layout.

 - The interface provide callbacks for selection and unselection of tabs as well.

 - If your adapter doesn't implement the interface `CustomTabProvider` the default tab will be used, which is a `TextView` with id `R.id.psts_tab_title`).

5. (可选)如果你使用OnPageChangeListener你的看法寻呼机,你应该把它在小部件,而不是直接在寻呼机。

   //从上面延续 
   标签 setOnPageChangeListener(mPageChangeListener);

定制

从主题:

说明一些原生属性:

自定义属性:

几乎所有的属性都有其各自的getter和setter方法在运行时改变它们。动态地改变pstsTabTextFontFamilypstsTabTextStyle您可以拨打:

上一篇:切换到指定页再加载数据的ViewPager
下一篇:Android仿钢琴律动效果源码下载

相关内容

热门推荐