Giter Site home page Giter Site logo

androidsegmentcontrol's Introduction

AndroidSegmentControl

Introduction

A android custom view works like SegmentControl in IOS

Usage

  • Add the below code in you layout xml file
<com.huibin.androidsegmentcontrol.SegmentControl
        xmlns:segmentcontrol="http://schemas.android.com/apk/res-auto"
        android:id="@+id/segment_control"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        segmentcontrol:texts="未签到|全部|已签到" <!--标签的内容-->
        segmentcontrol:colors="#e00032"
        segmentcontrol:cornerRadius="5dip"
        segmentcontrol:direction="horizon" <!--标签的显示的方向-->
        segmentcontrol:verticalGap="8dip"
        segmentcontrol:horizonGap="8dip"
        segmentcontrol:selectedIndex="1"/><!--默认选中哪个标签,默认是0,当大于标签的个数就默认选中为最后一个标签-->
  • Then add these code
SegmentControl segmentControl = (SegmentControl) findViewById(R.id.segment_control);
segmentControl.setmOnSegmentControlClickListener(new SegmentControl.OnSegmentControlClickListener() {
    @Override 
    public void onSegmentControlClick(int index) {
        //处理点击标签的事件
    } 
}); 
  • Enjoy yourself

Screen snapshot

snapshot

androidsegmentcontrol's People

Watchers

 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.