• Stars
    star
    377
  • Rank 113,103 (Top 3 %)
  • Language
    Java
  • Created over 8 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

仿微信底部tab标签,滑动的时候颜色渐变,使用极其简单,只需要两行代码。

AlphaIndicatorView

仿微信底部tab标签,滑动的时候颜色渐变,使用极其简单,只需要两行代码。

欢迎大家下载体验本项目,如果使用过程中遇到什么问题,欢迎反馈。

联系方式

  • 邮箱地址: [email protected]
  • QQ群: 489873144 (建议使用QQ群,邮箱使用较少,可能看的不及时)
  • 本群刚建立,旨在为使用我的github项目的人提供方便,如果遇到问题欢迎在群里提问。个人能力也有限,希望一起学习一起进步。

演示

imageimageimage

1.用法

该项目和我github上其他的view相关的项目已经一起打包上传到jCenter仓库中(源码地址 https://github.com/jeasonlzy0216/ViewCore ),使用的时候可以直接使用compile依赖,用法如下

	compile 'com.lzy.widget:view-core:0.1.5'

或者使用

    compile project(':alphaview')

注意事项

该项目可以自动判断每一个Tab中的View,是否具有图标和文字,允许出现以下三种情况:

  • 自定义属性只设置了 tabText ,表示只有文字,滑动时文字颜色渐变过度
  • 自定义属性只设置了 tabIconNormal 和 tabIconSelected ,表示只有图标,滑动时图标颜色渐变过度
  • 以上两种都设置了,表示文字和图标同时渐变过度

功能和参数含义

配置参数 参数含义
tabIconNormal 未选中的图标
tabIconSelected 已经选中的图标
tabText tab标签的文字
tabTextSize tab标签的文字大小
textColorNormal 未选中的文字颜色
textColorSelected 已选中的文字颜色

3.代码参考

1.在Activity中做如下初始化,只需要找到控件并且设置ViewPager即可完成。

	protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
        viewPager.setAdapter(new MainAdapter(getSupportFragmentManager()));
        AlphaIndicator alphaIndicator = (AlphaIndicator) findViewById(R.id.alphaIndicator);
        alphaIndicator.setViewPager(viewPager);
    }

2.布局文件

	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">

    <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <View
        android:layout_width="match_parent"
        android:layout_height="1px"
        android:background="#888"/>

    <com.lzy.widget.AlphaIndicator
        android:id="@+id/alphaIndicator"
        android:layout_width="match_parent"
        android:layout_height="55dp"
        android:orientation="horizontal">

        <com.lzy.widget.AlphaView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:padding="5dp"
            app:av_tabIconNormal="@mipmap/home_normal"
            app:av_tabIconSelected="@mipmap/home_selected"
            app:av_tabText="微信"
            app:av_tabTextSize="14sp"
            app:av_textColorNormal="#999999"
            app:av_textColorSelected="#46c01b"/>

        <com.lzy.widget.AlphaView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:padding="5dp"
            app:av_tabIconNormal="@mipmap/category_normal"
            app:av_tabIconSelected="@mipmap/category_selected"
            app:av_tabText="通讯录"
            app:av_tabTextSize="14sp"
            app:av_textColorNormal="#999999"
            app:av_textColorSelected="#46c01b"/>

        <com.lzy.widget.AlphaView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:padding="5dp"
            app:av_tabIconNormal="@mipmap/service_normal"
            app:av_tabIconSelected="@mipmap/service_selected"
            app:av_tabText="发现"
            app:av_tabTextSize="14sp"
            app:av_textColorNormal="#999999"
            app:av_textColorSelected="#46c01b"/>

        <com.lzy.widget.AlphaView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:padding="5dp"
            app:av_tabIconNormal="@mipmap/mine_normal"
            app:av_tabIconSelected="@mipmap/mine_selected"
            app:av_tabText=""
            app:av_tabTextSize="14sp"
            app:av_textColorNormal="#999999"
            app:av_textColorSelected="#46c01b"/>
    </com.lzy.widget.AlphaIndicator>
</LinearLayout>
	

More Repositories

1

okhttp-OkGo

OkGo - 3.0 震撼来袭,该库是基于 Http 协议,封装了 OkHttp 的网络请求框架,比 Retrofit 更简单易用,支持 RxJava,RxJava2,支持自定义缓存,支持批量断点下载管理和批量上传管理功能
Java
10,586
star
2

ImagePicker

完全仿微信的图片选择,并且提供了多种图片加载接口,选择图片后可以旋转,可以裁剪成矩形或圆形,可以配置各种其他的参数
Java
4,289
star
3

NineGridView

类似QQ空间,微信朋友圈,微博主页等,展示图片的九宫格控件,自动根据图片的数量确定图片大小和控件大小,使用Adapter模式设置图片,对外提供接口回调,使用接口加载图片,支持任意的图片加载框架,如 Glide,ImageLoader,Fresco,xUtils3,Picasso 等,支持点击图片全屏预览大图。
Java
2,463
star
4

HeaderViewPager

具有共同头部的 ViewPager,支持与ListView,GridView,ScrollView,WebView,RecyclerView 嵌套使用。具有连续的滑动事件 和 滑动监听, 支持下拉刷新。
Java
767
star
5

VerticalSlideView

类似淘宝的商品详情页,继续拖动查看详情,其中拖动增加了阻尼,并且重写了ListView,GridView,ScrollView,WebView,RecyclerView 的 dispatchTouchEvent 方法,使用的时候无须额外的代码,可以任意嵌套使用。
Java
710
star
6

PullZoomView

类似QQ空间,新浪微博个人主页下拉头部放大的布局效果,支持ListView,GridView,ScrollView,WebView,RecyclerView,以及其他的任意View和ViewGroup。支持头部视差动画,阻尼下拉放大,滑动过程监听。
Java
591
star
7

ViewCore

主要是常用自定义控件的类库,该项目已经上传到 jCenter 仓库,可以直接使用
Java
200
star
8

OverScrollDecor

类似IOS的over-scrolling效果,即对于滑动到顶部的View继续滑动时会超出,松手后自动还原到原始位置。支持ListView,GridView,ScrollView,WebView,RecyclerView,以及其他的任意View和ViewGroup。
Java
129
star
9

HexagonView

六边形带圆角的自定义View,支持图文混排,点击区域,水平垂直方向切换,圆角大小等各种属性
Java
46
star
10

Screenshots

2
star
11

YaoBi

Java
1
star