Giter Site home page Giter Site logo

changetablayout's Introduction

ChangeTabLayout

Stars LICENSE 作者

ChangeTabLayout是模仿乐视LIVE App主界面TabLayout效果。

Preview

原效果图

原效果图转为Gif过大,所以将录制的MP4效果视频已经放入了根目录的preview文件夹内,有兴趣可去查看。

实现效果图

preview

ChangeTabLayout在打开状态时

  • 垂直方向切换时,文字的颜色大小变化。
  • 水平方向切换时,文字的渐变与图片的变化。

ChangeTabLayout在收起状态时

  • 垂直方向切换时,图片的变化。
  • 点击ChangeTabLayout,切换为打开状态。

使用说明

因为使用场景的局限性等原因,暂时不上传至Maven中心仓库中,仅提供参考学习用途。

xml使用部分

    <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v4.view.VerticalViewPager
            android:id="@+id/viewpager"
            android:background="@color/bg"
            android:layout_width="match_parent"
            android:fadingEdge="none"
            android:overScrollMode="never"
            android:layout_height="match_parent"/>

        <com.github.zl.changetablayout.ChangeTabLayout
            android:id="@+id/tabLayout"
            android:layout_width="110dp"
            android:layout_height="match_parent"/>

    </FrameLayout>

代码使用部分

   VerticalViewPager mViewPager = (VerticalViewPager) this.findViewById(R.id.viewpager);
   //只传入自己想要变化的图片,颜色属性生效
   mTabLayout.setViewPager(mViewPager, icon, null);
   //传入默认图片与选中图片,颜色属性不生效
   mTabLayout.setViewPager(mViewPager, iconDefault, iconSelected);

   //监听TabLayout点击事件
   mTabLayout.setOnTabClickListener(new ChangeTabLayout.OnTabClickListener() {
       @Override
       public void onTabClicked(int position) {

       }
   });

   //出入水平方向Page滚动参数,实现TabLayout的收缩效果(可选)
   mTabLayout.setPageScrolled(page, position, positionOffset);

属性说明

xml 默认值 说明
app:ctl_tabViewColor 默认为#161616 Tab背景颜色
app:ctl_indicatorColor 默认为#70000000 指示器背景色
app:ctl_leftBorderColor 默认为#cf212b 指示器左侧竖条颜色
app:ctl_tabViewHeight 默认为50dp Tab高度
app:ctl_tabImageHeight 默认为18dp Tab中图片高度(宽度)
app:ctl_tabViewShadowColor 默认为#161616 Tab收起时阴影颜色
app:ctl_indicatorPadding 默认为4dp 指示器与Tab的上下边距之和
app:ctl_defaultTabTextSize 默认为14sp Tab中文字默认大小
app:ctl_leftBorderThickness 默认为3dp 指示器左侧竖条宽度
app:ctl_defaultTabTextColor 默认为#494949 Tab中文字默认颜色
app:ctl_selectedTabTextColor 默认为#ffffff Tab中文字选中颜色
app:ctl_defaultTabImageColor 默认为#494949 Tab中图片默认颜色
app:ctl_selectedTabImageColor 默认为#cf212b Tab中图片选中颜色

实现过程

具体参考这篇博客:ChangeTabLayout实现过程

TODO

  1. TabView中兼容多行文字。
  2. 竖屏状态下ViewPageonPageScrolled监听不正常。

Thanks For

License

Copyright 2017 simplezhli

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

changetablayout's People

Contributors

simplezhli avatar

Watchers

James Cloos avatar Steve Li avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.