Android滑动页面导航效果: PagerSlidingTabStrip
2016-02-24 16:18
561 查看
把github上的PagerSlidingTabStrip稍作修改:
tab的文字颜色选中变色(原版文字不变色),类似微信导航
栗子:http://download.csdn.net/detail/onlyonecoder/7722021
PagerSlidingTabStrip 自定义属性列表:
修改后加了一个属性 selectedTabTextColor
如果不设置 默认和 滑动指示器颜色(pstsIndicatorColor)一致
下图效果的代码:
[html] view
plain copy
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res/org.lmw.demo.slidingtab">
<org.lmw.demo.slidingtab.widget.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="40dp"
app:pstsShouldExpand="true"
app:pstsUnderlineHeight="2dp"
app:pstsIndicatorHeight="2dp"
app:pstsIndicatorColor="@android:color/holo_blue_light"
app:selectedTabTextColor="@android:color/holo_blue_light"
app:pstsDividerColor="@android:color/transparent"
app:pstsTabBackground="@drawable/background_tab"
android:background="@android:color/white"
/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tabs" />
</RelativeLayout>
tab的文字颜色选中变色(原版文字不变色),类似微信导航
栗子:http://download.csdn.net/detail/onlyonecoder/7722021
PagerSlidingTabStrip 自定义属性列表:
pstsIndicatorColorColor of the sliding indicator
pstsUnderlineColorColor of the full-width line on the bottom of the view
pstsDividerColorColor of the dividers between tabs
pstsIndicatorHeightHeight of the sliding indicator
pstsUnderlineHeightHeight of the full-width line on the bottom of the view
pstsDividerPaddingTop and bottom padding of the dividers
pstsTabPaddingLeftRightLeft and right padding of each tab
pstsScrollOffsetScroll offset of the selected tab
pstsTabBackgroundBackground drawable of each tab, should be a StateListDrawable
pstsShouldExpandIf set to true, each tab is given the same weight, default false
pstsTextAllCapsIf true, all tab titles will be upper case, default true
修改后加了一个属性 selectedTabTextColor
如果不设置 默认和 滑动指示器颜色(pstsIndicatorColor)一致
下图效果的代码:
[html] view
plain copy
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res/org.lmw.demo.slidingtab">
<org.lmw.demo.slidingtab.widget.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="40dp"
app:pstsShouldExpand="true"
app:pstsUnderlineHeight="2dp"
app:pstsIndicatorHeight="2dp"
app:pstsIndicatorColor="@android:color/holo_blue_light"
app:selectedTabTextColor="@android:color/holo_blue_light"
app:pstsDividerColor="@android:color/transparent"
app:pstsTabBackground="@drawable/background_tab"
android:background="@android:color/white"
/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tabs" />
</RelativeLayout>
相关文章推荐
- android 2.3系统闹钟中 重复项的思路
- 从源码编译Android系统的Java类库和JNI动态库的方法
- Android Studio方法前添加自己的注释
- Android事件分发机制完全解析(一)
- android 常用代码github下载地址
- android apk的编译过程
- 利用源码编译Android系统的APK和可执行命令的方法
- android ndk编写
- Android自定义控件之仿美团下拉刷新
- windows下 更新 android studio SDK 到最新版本 解决方案
- Android样式之drawable
- Android中基于XMPP协议实现IM聊天程序与多人聊天室
- Android性能优化之Bitmap的内存优化
- Android 欢迎引导页的魅力
- Android 快速开发框架:推荐10个框架
- Android命令行查看内存情况
- Android BroadcastReceiver
- 2015年Android 开发有哪些新技术出现?
- 直接拿来用!最火的Android开源项目整理
- 使用android.view.TouchDelegate扩大View的触摸点击区域