Coder Social home page Coder Social logo

sidebar's Introduction

Sidebar

side or navigation bar

Sidebar 配置

          // 显示文字, default: false
          sidebarView.isShowText(true);
          
          // 默认选中 index ; 不默认选中 则为 -1; 当 setViewPager 时, mCurrentItem value set 0
          sidebarView.setDefaultSelectItemOfIndex(-1);
    
          // 点击 item 是否改变 Sidebar 的背景颜色, default: false
          sidebarView.isClickChangeBackgroundColor(false);
           
          // Sidebar 背景颜色, 当 显示动画效果且 index >= 0 时, 失效
          sidebarView.setBaseBackgroundColor(getResources().getColor(R.color.colorPink));
      
          // 选中 Item 的颜色
          sidebarView.setItemSelectedColor(getResources().getColor(R.color.colorWhite));
    
          // 未选中 Item 的颜色
          sidebarView.setItemUnSelectedColor(getResources().getColor(R.color.colorGray));
    
          sidebarView.setItemSelectedTextColor(getResources().getColor(R.color.itemClickColor));
          sidebarView.setItemUnSelectedTextColor(getResources().getColor(R.color.colorCC));

          // 设置textSize, default: 12sp
          sidebarView.setSelectedTextSize(32);
          sidebarView.setUnSelectedTextSize(32);

          // Sidebar 方向, default: horizontal
          sidebarView.orientationIsVertical();
    
          // Sidebar 横向的高度 或者 竖向 item 的宽高
          sidebarView.setSidebarWidth(100);
    
          // 点击 item 是否有动画效果, default:true
          sidebarView.isAnimator(false);
    
          // 点击事件响应已选中 Item, default: false
          sidebarView.isSelectedItemClick(true);
    
          // if isAnimator is true, 点击 Item, Item 偏移量, default: 30
          sidebarView.setAnimatorPadding(30);
    
          // if isAnimator is true, Item 初始偏移量, default:10
          sidebarView.setInitializePadding(10);
    
          // 隐藏 Item, 传值类型为 int[] 数组, 当某个 Item 或者多个 Item 暂时不需要时,设置该项
          sidebarView.setItemGone(new int[]{1});

Sidebar 在左侧

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:orientation="horizontal">
    
    <com.github.chengheaven.sidebar.SidebarView
        android:id="@+id/sidebar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    
    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    
</LinearLayout>

将 orientation 的方向改为 vertical , 则 Sidebar 在上方

Sidebar 在下方布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white">
    
    <com.github.chengheaven.sidebar.SidebarView
        android:id="@+id/sidebar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />
    
    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/sidebar" />
    
</RelativeLayout>

sidebar's People

Contributors

chengheaven avatar heavencheng avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

pensokha

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.