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),请尊重他人的辛勤劳动成果,谢谢! 本篇文章 ...
随机推荐
- javascript快速入门9--引用类型
引用类型通常叫做类(class),也就是说,遇到引用值,所处理的就是对象. 注意:从传统意义上来说,ECMAScript 并不真正具有类.事实上,除了说明不存在类,在 ECMA-262 中根本没有出现 ...
- GPU Instance
http://forum.china.unity3d.com/thread-17131-1-1.html https://docs.unity3d.com/Manual/GPUInstancing.h ...
- 【业务自动化】iTop,全面支持ITIL流程的一款ITSM工具
iTop产品针对的主要应用场景为:内部IT支持.IT外包管理.数据中心运维管理和企业IT资产管理.常青管理从绿象认证产品中选取了iTop作为主要推荐产品,本类别的绿象认证产品还包括:OTRS和RT3等 ...
- Spark(五) -- Spark Streaming介绍与基本执行过程
Spark Streaming作为Spark上的四大子框架之一,肩负着实时流计算的重大责任 而相对于另外一个当下十分流行的实时流计算处理框架Storm,Spark Streaming有何优点?又有何不 ...
- LintCode - Merge Two Sorted List
LintCode - Merge Two Sorted Lists LintCode - Merge Two Sorted Lists Web Link Description Code - C Ti ...
- 用C++实现Huffman文件编码和解码(2 总结)
这个是代码是昨天写完的,一开始的时候还出了点小bug,这个bug在晚上去吃饭的路上想明白的,回来更改之后运行立刻完成最后一步,大获成功. 简单说下huffman编码和文件压缩主要的技术. Huffma ...
- css - 公众号样式
/* * @Author: WJ_LONG * @Date: 2018-09-06 15:32:06 * @Last Modified by: WJ_LONG * @Last Modified tim ...
- selenuim-webdriver注解之@FindBy、@FindBys、@FindAll的区别
selenium-webdriver中获取页面元素的方式有很多,使用注解获取页面元素是其中一种途径, 方式有3种:@FindBy.@FindBys.@FindAll.下文对3中类型的区别和使用场景进行 ...
- 基于STC12C5A的MINI3216多功能点阵时钟
代码地址如下:http://www.demodashi.com/demo/12862.html 基于STC12C5A的MINI3216多功能点阵时钟 硬件详解 PCB 硬件原理图 主控模块 max72 ...
- 阿里云创建RAM子账号
操作步骤 创建子账号 主账号导航至 访问控制 > 用户管理 页面.如下图所示: 单击右上角的 新建用户,如下图所示: 填写弹出框的各配置项,如下图所示: 单击 确定,即可创建子账号. 允许子账号 ...