{"id":23136564,"url":"https://github.com/7heaven/shsegmentcontrol","last_synced_at":"2025-04-05T02:02:53.622Z","repository":{"id":30828737,"uuid":"34386102","full_name":"7heaven/SHSegmentControl","owner":"7heaven","description":"segmentcontrol widget for android","archived":false,"fork":false,"pushed_at":"2022-02-28T06:43:58.000Z","size":264,"stargazers_count":611,"open_issues_count":5,"forks_count":142,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-29T01:02:48.345Z","etag":null,"topics":["radiogroup","segmentcontrol","selector"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/7heaven.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-22T11:17:39.000Z","updated_at":"2024-06-17T08:56:14.000Z","dependencies_parsed_at":"2022-08-29T09:01:36.977Z","dependency_job_id":null,"html_url":"https://github.com/7heaven/SHSegmentControl","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7heaven%2FSHSegmentControl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7heaven%2FSHSegmentControl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7heaven%2FSHSegmentControl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7heaven%2FSHSegmentControl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/7heaven","download_url":"https://codeload.github.com/7heaven/SHSegmentControl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276159,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["radiogroup","segmentcontrol","selector"],"created_at":"2024-12-17T12:21:22.770Z","updated_at":"2025-04-05T02:02:53.598Z","avatar_url":"https://github.com/7heaven.png","language":"Java","readme":"[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SHSegmentControl-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/1770) [![jitpack](https://img.shields.io/github/tag/7heaven/SHSegmentControl.svg?label=JitPack%20Maven)](https://img.shields.io/github/release/7heaven/SHSegmentControl.svg?label=JitPack%20Maven) [![Build Status](http://img.shields.io/travis/7heaven/SHSegmentControl.svg)](https://travis-ci.org/7heaven/SHSegmentControl)\n[![License](https://img.shields.io/badge/apache-2.0-orange.svg)](LICENSE)\n[ ![Download](https://api.bintray.com/packages/7heaven/maven/SHSegmentControl/images/download.svg) ](https://bintray.com/7heaven/maven/SHSegmentControl/_latestVersion)\n\n### 中文\n\n# a simple SegmentControl Widget\n\n![art2](arts/arts2.gif)\n\n![art1](arts/arts1.gif)\n\n## 使用：\n\n### 添加依赖到build.gradle：\n\n\n```groovy\ndependencies {\n    compile 'com.7heaven.widgets:segmentcontrol:1.17'\n}\n```\n\n**相关属性:**\n\n* **selectedColor** 设置选中后的颜色\n* **normalColor** 设置未选中的颜色\n* **textColors** 设置文字内容的颜色，可以使用ColorStateList来设置选中和未选中的颜色，这个属性设置以后，之前设置的selectedColor和normalColor对文字内容失去作用\n* **backgroundColors** 设置边框、选中的背景和分割线的颜色，可以使用ColorStateList来同事设置选中和未选中的颜色，和textColors一样，设置这个属性后，selectedColor和normalColor会对边框和背景失去作用\n* **cornerRadius** 设置背景的圆角半径\n* **boundWidth** 设置边框的粗细\n* **separatorWidth** 设置分割线的粗细\n* **texts** 设置文字内容，通过'|'分隔开\n* **verticalGap** 纵向上的边距\n* **horizonGap** 横向的边距\n\n``` xml\n\u003ccom.sevenheaven.segmentcontrol.SegmentControl\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:id=\"@+id/segment_control\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:layout_marginTop=\"20dp\"                       \t\n    android:textSize=\"18sp\"\n\tapp:block_direction=\"horizontal\"\n    app:selectedColor=\"#32ADFF\"\n\tapp:normalColor=\"#FFFFFF\"\n    app:textColors=\"@color/text_colors\"\n    app:backgroundColors=\"@color/background_color\"\n    app:cornerRadius=\"5dp\"\n    app:separatorWidth=\"2dp\"\n    app:boundWidth=\"4dp\"\n    app:texts=\"啊啊|啦啦啦|哈哈哈|顶顶顶顶\"\n    app:verticalGap=\"10dp\"\n    app:horizonGap=\"10dp\"/\u003e\n```\n\n使用OnSegmentControlClickListener来监听选中的变换\n\n```java\nmSegmentHorzontal = (SegmentControl) findViewById(R.id.segment_control);\nmSegmentHorzontal.setOnSegmentControlClickListener(new SegmentControl.OnSegmentControlClickListener() {\n    @Override\n    public void onSegmentControlClick(int index) {\n        Log.i(TAG, \"onSegmentControlClick: index = \" + index);\n    }\n});\n```\n\n### English\n\n# a simple SegmentControl Widget\n\n![art2](arts/arts2.gif)\n\n![art1](arts/arts1.gif)\n\n## Usage：\n\n### add dependency to build.gradle：\n\n\n```groovy\ndependencies {\n    compile 'com.7heaven.widgets:segmentcontrol:1.16'\n}\n```\n\n**Attributes:**\n\n* **selectedColor** attribute for setting the selected color\n* **normalColor** attribute for setting the unselected color\n* **textColors** attribute for setting text colors, this attribute accept ColorStateList so you can set text selected color \u0026 text unselected color using this attribute,once this attribute is set, the previously selectedColor \u0026 normalColor attributes will not affect the text color\n* **backgroundColors** for setting the round corner background stroke color, separators color \u0026 selected background color,same as textColors, when this attribute is set, previously selectedColor \u0026 normalColor attributes will not affect the background color, this attribute accept ColorStateList\n* **cornerRadius** setting the corner radius of the background\n* **boundWidth** setting the round corner background stroke width\n* **separatorWidth** setting width of separators\n* **texts** setting the string contents, separated by '|'\n* **verticalGap** vertical padding\n* **horizonGap** horizontal padding\n\n**noticed that textColors \u0026 backgroundColors has higher priority than selectedColor \u0026 normalColor**\n\n``` xml\n\u003ccom.sevenheaven.segmentcontrol.SegmentControl\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:id=\"@+id/segment_control\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:layout_marginTop=\"20dp\"                       \t\n    android:textSize=\"18sp\"\n\tapp:block_direction=\"horizontal\"\n    app:selectedColor=\"#32ADFF\"\n\tapp:normalColor=\"#FFFFFF\"\n    app:textColors=\"@color/text_colors\"\n    app:backgroundColors=\"@color/background_color\"\n    app:cornerRadius=\"5dp\"\n    app:separatorWidth=\"2dp\"\n    app:boundWidth=\"4dp\"\n    app:texts=\"啊啊|啦啦啦|哈哈哈|顶顶顶顶\"\n    app:verticalGap=\"10dp\"\n    app:horizonGap=\"10dp\"/\u003e\n```\n\nusing OnSegmentControlClickListener to listen to segment change event.\n\n```java\nmSegmentHorzontal = (SegmentControl) findViewById(R.id.segment_control);\nmSegmentHorzontal.setOnSegmentControlClickListener(new SegmentControl.OnSegmentControlClickListener() {\n    @Override\n    public void onSegmentControlClick(int index) {\n        Log.i(TAG, \"onSegmentControlClick: index = \" + index);\n    }\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7heaven%2Fshsegmentcontrol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F7heaven%2Fshsegmentcontrol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7heaven%2Fshsegmentcontrol/lists"}