Android-ViewPagerIndicator框架使用——LinePageIndicator
前言:LinePageIndicator类似CirclePageIndicator,只是将圆点指示变成了长条指示。
一:使用是定义的布局文件simple_lines :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" /> <com.viewpagerindicator.LinePageIndicator
android:id="@+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip" />
</LinearLayout>
二:代码中使用:
setContentView(R.layout.simple_lines); mAdapter = new TestFragmentAdapter(getSupportFragmentManager()); ViewPager mPager = (ViewPager) findViewById(R.id.pager);
mPager.setAdapter(mAdapter); LinePageIndicator mIndicator = (LinePageIndicator) findViewById(R.id.indicator);
mIndicator.setViewPager(mPager);
三:修改属该改变样式,下边可以修改的属性值:
<declare-styleable name="LinePageIndicator"> <!-- 是否居中显示 -->
<attr name="centered" />
<!-- 没有被选择标识的颜色 -->
<attr name="unselectedColor" />
<!-- 被选择标识的颜色 -->
<attr name="selectedColor" />
<!-- 标识的宽度大小 -->
<attr name="lineWidth" format="dimension" />
<!-- 标识的高度 -->
<attr name="strokeWidth" />
<!-- 标识间隔大小 -->
<attr name="gapWidth" format="dimension" />
<!-- 整体的背景色 -->
<attr name="android:background" />
</declare-styleable>
1.代码修改样式:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_lines); mAdapter = new TestFragmentAdapter(getSupportFragmentManager()); mPager = (ViewPager) findViewById(R.id.pager);
mPager.setAdapter(mAdapter); LinePageIndicator indicator = (LinePageIndicator) findViewById(R.id.indicator);
mIndicator = indicator;
indicator.setViewPager(mPager);
// 获得屏幕的密度
final float density = getResources().getDisplayMetrics().density;
indicator.setSelectedColor(0x88FF0000);
indicator.setUnselectedColor(0xFF888888);
indicator.setStrokeWidth(4 * density);
indicator.setLineWidth(30 * density);
}
2.布局中修改:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" /> <com.viewpagerindicator.LinePageIndicator
android:id="@+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
app:lineWidth="30dp"
app:selectedColor="#FF880000"
app:strokeWidth="4dp"
app:unselectedColor="#FF888888" />
</LinearLayout>
3.主题方式修改:
<activity
android:name=".SampleLinesStyledTheme"
android:label="Lines/Styled (via theme)"
android:theme="@style/CustomLinePageIndicator" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="com.jakewharton.android.viewpagerindicator.sample.SAMPLE" />
</intent-filter>
</activity>
主题:
<style name="CustomLinePageIndicator" parent="@android:style/Theme.Light">
<item name="strokeWidth">4dp</item>
<item name="lineWidth">30dp</item>
<item name="unselectedColor">#FF888888</item>
<item name="selectedColor">#FF880000</item>
</style>
源码以及Demo下载地址:http://download.csdn.net/detail/as294985925/6796117
Android-ViewPagerIndicator框架使用——LinePageIndicator的更多相关文章
- Android开源框架ViewPagerIndicator的基本使用
转载本博客请注明出处:点击打开链接 http://blog.csdn.net/qq_32059827/article/details/52495647 很多新闻资讯类的app都有一些共性,那就是 ...
- Android百大框架排行榜
Android百大框架排行榜 15类Android通用流行框架 - 流风,飘然的风 - 博客园https://www.cnblogs.com/zdz8207/p/android-opensource- ...
- 2017年Android百大框架排行榜
框架:提供一定能力的小段程序 >随意转载,标注作者"金诚"即可 >本文已授权微信公众号:鸿洋(hongyangAndroid)原创首发. >本文已经开源到Gith ...
- android 优秀框架整理
程序员界有个神奇的网站,那就是github,这个网站集合了一大批优秀的开源框架,极大地节省了开发者开发的时间,在这里我进行了一下整理,这样可以使我们在使用到时快速的查找到,希望对大家有所帮助! 1. ...
- 2017年Android百大框架排行榜(转)
一.榜单介绍 排行榜包括四大类: 单一框架:仅提供路由.网络层.UI层.通信层或其他单一功能的框架 混合开发框架:提供开发hybrid app.h5与webview结合能力.web app能力的框架 ...
- Android开源框架ViewPageIndicator和ViewPager实现Tab导航
前言: 关于使用ViewPageIndicator和ViewPager实现Tab导航,在开发社区里已经有一堆的博客对其进行了介绍,假设我还在这里写怎样去实现.那简直就是老生常谈,毫无新奇感,并且.我也 ...
- Android 开源框架Universal-Image-Loader学习
Android 开源框架Universal-Image-Loader完全解析(一)--- 基本介绍及使用 Android 开源框架Universal-Image-Loader完全解析(二)--- 图片 ...
- Android 数据库框架OrmLite的使用(一)
在这里记录下最基本的用法,官网上可了解相关的介绍. 1.下载OrmLite jar 在下载android的:ormlite-android-4.48.jar和ormlite-core-4.48.jar ...
- Android 开源框架Universal-Image-Loader完全解析(三)---源代码解读
转载请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/39057201),请尊重他人的辛勤劳动成果,谢谢! 本篇文章 ...
随机推荐
- The method Inflate() in android
Inflate() method can find out a layout defined by xml,as like the findViewById() method,but there ha ...
- 本机搭建PHP环境全教程(图文)
为了更好的维护空间网站,研究和调试PHP程序,许多人需要在自己的计算机内搭建PHP环境.本文将介绍使用phpnow环境组件搭建的全过程.使用搜索工具,搜索phpnow<ignore_js_op& ...
- Fillrate
http://xionggf.com/articles/graphic/misc/mobile_gpu_term.html IMR Immediate Mode Rendering 立即渲染模式 TB ...
- 【OpenStack项目管理-CPU/内存/存储/网络 配额管理】
参考资料: OpenStack如何管理项目和用户:http://os.51cto.com/art/201312/422010.htm Nova.Cinder.Neutron资源配额设置:http:// ...
- 转:http2的资料与使用
https://imququ.com/post/http2-resource.html
- c# 用OpenXmL读取.xlsx格式的Excel文件 返回DataTable
1.须要引用的dll : DocumentFormat.OpenXml.dll ---须要安装一下OpenXml再引用 WindowsBase ---直接在项目里加入引用 2.方法: /// & ...
- Zigbee事件
ZIGBEE事件有两类.系统定义事件和用户定义事件. 系统类事件是协议栈已定义好的.用户类事件是我们用户层面来定义的. 事件类号採用一个16bit的常量,使用独热码编码,独热码是仅仅有一个bit为1, ...
- Linux——获取IP及其中发现的问题
由于最近在学习网络编程,喜欢玩IP地址. 首先,我需要搞清楚如何获得本机IP. ===========================================11.04============ ...
- Jenkins部署java项目实例
源码管理 选择 “git”, Repository URL填写你的git地址,并配置对应的key,大家最好事前先在jenkins这台机器上能够直接远程git操作私有仓库 构建触发器.构建环境.Pre ...
- 阿里云OSS服务开通STS安全令牌
搭建直传服务需要完成以下准备工作: 开通OSS,并且创建Bucket. 开通STS服务. 登录 OSS管理控制台. 在OSS概览页中找到基础配置区域,单击 安全令牌,如下图所示: 进入到 安全令牌快捷 ...