在AndroidStudio中使用PagerSlidingTabStrip
来源:互联网 发布:html5引导动画源码 编辑:程序博客网 时间:2024/04/30 23:04
今天花了一天的时间,写了一个属于自己的开发框架,其中有一个是PagerSlidingTabStrip+fragment+viewpager框架,用了新的PagerSlidingTabStrip,这里记一下经验。
1.首先在AndroidStudio中加载依赖:
<span style="font-size:18px;">compile 'com.jpardogo.materialtabstrip:library:1.0.9'</span>
2.布局中声明:
<com.astuetz.PagerSlidingTabStrip android:id="@+id/tabs" app:pstsShouldExpand="true" app:pstsIndicatorColor="@color/lightred" app:pstsTextColorSelected="@color/lightred" android:layout_width="match_parent" android:layout_height="40dp" android:background="@color/white" android:textColor="@color/lightblack" />
3.java代码中使用:
viewPager.setAdapter(pageAdapter);tabs.setViewPager(viewPager);
4.相关属性,这里直接从github上copy下来了:
个人认为有上面定义的属性已经足够使用了
Notes about some of the native attr:
android:textColor
Non selected tabs text color. If you DO definetextColor
It will be apply toNON selected tabs and NO ALPHA will be applied to them, the colour you define is the one you will see. If you want to define a half transparent color intextColor
, you can pass #80FFFFFF (That's an example for half transparent white)android:textSize
Tab text sizeandroid:paddingLeft
orandroid:paddingRight
layout padding. If you apply both, they should be balanced. PR #69 have a good explanation of this behaviour.
Custom attr:
pstsIndicatorColor
Color of the sliding indicator.textPrimaryColor
will be it's default color value.pstsUnderlineColor
Color of the full-width line on the bottom of the view.textPrimaryColor
will be it's default color value.pstsUnderlineHeight
Height of the full-width line on the bottom of the view.pstsTextAlpha
Set the text alpha transparency for non selected tabs. Range 0..255. 150 is it's default value. It WON'T be use iftextColor
is defined in the layout. IftextColor
is NOT defined, It will be apply to the non selected tabs.pstsTextColorSelected
Set selected tab text color.textPrimaryColor
will be it's default color value.pstsTextStyle
Set the text style, default bold.pstsTextSelectedStyle
Set the text style of the selected tab, default bold.pstsTextAllCaps
If true, all tab titles will be upper case, default true.pstsDividerColor
Color of the dividers between tabs.textPrimaryColor
will be it's default color value.pstsDividerPadding
Top and bottom padding of the dividers.pstsDividerWidth
Stroke width of divider line, defaults to 0.pstsIndicatorHeight
Height of the sliding indicator.pstsTabPaddingLeftRight
Left and right padding of each tab.pstsScrollOffset
Scroll offset of the selected tab.pstsTabBackground
Background drawable of each tab, should be a StateListDrawable.pstsShouldExpand
If set to true, each tab is given the same weight, default false.pstsPaddingMiddle
If true, the tabs start at the middle of the view (Like Newsstand google app).
0 0
- 在AndroidStudio中使用PagerSlidingTabStrip
- 在AndroidStudio中使用GreenDAO
- HttpClient在 AndroidStudio中使用
- 在AndroidStudio中使用Kotlin
- 在AndroidStudio中使用SVN
- 在AndroidStudio中使用ARCore
- 在AndroidStudio中使用Git和GitHub
- 在AndroidStudio中使用Lambda表达式
- 在AndroidStudio中使用Lambda表达式
- 在AndroidStudio中使用Lambda表达式
- 如何在AndroidStudio中使用AIDL
- 在AndroidStudio中使用NDK配置方法
- 在AndroidStudio中导入SlidingMenu并使用
- 如何在AndroidStudio中使用git
- 在AndroidStudio中配置使用ButterKnife
- 像在vim在中一样使用androidstudio
- Android中使用开源框架PagerSlidingTabStrip实现导航标题
- PagerSlidingTabStrip使用问题大合集
- bootstrap入门【组件之按钮组,下拉菜单,嵌套】
- PHP记录
- 二月末,三月初
- 浅谈java内存
- YCSB性能测试工具使用
- 在AndroidStudio中使用PagerSlidingTabStrip
- 在Code::Blocks中配置OpenGL
- C Language Study - 指针的形式 & 下标的形式
- 2014—2015年度总结
- use email as Username with MVC5 Microsoft.AspNet.Identity
- 关于工作量估算,你知道的和你不知道的一切
- System/Runtime/Calendor系统常用类
- Redis集群功能预览
- win7 iis php出现404.17错误