Git Product home page Git Product logo

segmentedcontrol's Introduction

SegmentedControlButton

自定义View实现的分段选择控件

  • 支持拖动和点击手势
  • 支持松手动画
  • 支持自定义样式
  • 支持字体颜色过渡

APK下载

效果图

使用

  • Step 1. 在项目根目录build.gradle里面添加
	allprojects {
		repositories {
			...
			maven { url 'https://www.jitpack.io' }
		}
	}
  • Step 2. 添加依赖
	dependencies {
	        implementation 'com.github.danledian:SegmentedControl:1.0.5'
	}

示例

  • XML代码
    <com.dld.view.SegmentedControlView
        android:layout_width="300dp"
        android:layout_height="40dp"
        app:segItemHorizontalMargin="3dp"
        app:segItemVerticalMargin="3dp"
        app:segCornersMode="Circle"
        app:segSelectedItem="1"
        android:id="@+id/scv"/>
  • 添加数据
      List<SegmentedControlItem> items = new ArrayList<>();
      items.add(new SegmentedControlItem("Yesterday"));
      items.add(new SegmentedControlItem("Today"));
      items.add(new SegmentedControlItem("Tomorrow"));
      mScv1.addItems(items);

Attributes属性

Attributes format describe
segCornersRadius dimension 内外边框的弧度
segBackgroundColor color 背景颜色
segSelectedItemBackgroundColor color 移动Item的颜色
segTextColor color 背景中字体颜色
segSelectedItemTextColor color 移动Item的字体颜色
segItemHorizontalMargin dimension 移动Item距离边框的左外间距
segItemVerticalMargin dimension 移动Item距离边框的上外间距
segItemPadding dimension 设置Item左右内边距
segSelectedItem integer 设置选中位置
segTextSize reference 设置字体大小
segScrollSelectEnabled boolean 设置是否支持滑动选择
segCornersMode enum 设置模式

License

MIT

项目源码地址https://github.com/danledian/SegmentedControl,欢迎Star

segmentedcontrol's People

Contributors

danledian 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.