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),请尊重他人的辛勤劳动成果,谢谢! 本篇文章 ...
随机推荐
- projecteuler---->problem=11----Largest product in a grid
In the 2020 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 1 ...
- YUV12(420) (from)to RGB24
直接上代码 #include <opencv2/opencv.hpp> #include <stdio.h> #define min(a,b) ((a<b)?a:b) # ...
- IStorage
IStorage 接口支持结构化存储对象的创建和管理. 结构化存储允许分层存储在单个文件的信息,和通常被称为“文件系统内文件”. 元素的结构化存储对象存储和小溪. 存储类似于目录,和流类似于文件. 在 ...
- pickle和cPickle:Python对象的序列化(上)
https://segmentfault.com/a/1190000002493548 pickle模块实现了一种算法,将任意一个Python对象转化成一系列字节(byets).此过程也调用了seri ...
- 文档对象模型-DOM(一)
首先看一下DOM树结构: 每个节点都是一个对象,拥有方法和属性. 脚本可以访问以及更新DOM树(不是源代码). 针对DOM树的修改都会反映到浏览器. 访问并更新DOM树需要两个步骤: 一.定位到与 ...
- centos7,py2和py3共存
1.查看是否已经安装Python CentOS 7.2 默认安装了python2.7.5 因为一些命令要用它比如yum 它使用的是python2.7.5. 使用 python -V 命令查看一下是否安 ...
- 基于php的银行卡实名认证接口调用代码实例
银行卡二元素检测,检测输入的姓名.银行卡号是否一致. 银行卡实名认证接口:https://www.juhe.cn/docs/api/id/188 <?php // +-------------- ...
- POSTGRESQL同步——SLONY-I配置
来自:http://bbs.chinaunix.net/thread-955564-1-1.html 参考文档 http://bbs.chinaunix.net/viewthr ... page%3D ...
- Tabs or Spaces?
Never mix tabs and spaces. The most popular way of indenting Python is with spaces only. The second- ...
- Jmeter-安装及配置(一)
Apache JMeter是Apache组织开发的基于Java的压力测试工具.用于对软件做压力测试,它最初被设计用于Web应用测试,但后来扩展到其他测试领域. 它可以用于测试静态和动态资源,例如静态文 ...