{"id":21990098,"url":"https://github.com/skyhacker2/ecsegmentedcontrol","last_synced_at":"2025-09-12T12:46:29.090Z","repository":{"id":148897443,"uuid":"45536904","full_name":"skyhacker2/ECSegmentedControl","owner":"skyhacker2","description":"Android模仿iOS UISegmentedControl","archived":false,"fork":false,"pushed_at":"2015-11-05T03:42:59.000Z","size":320,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-13T08:18:46.241Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skyhacker2.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-04T12:15:29.000Z","updated_at":"2019-01-17T06:20:43.000Z","dependencies_parsed_at":"2023-04-12T03:04:21.684Z","dependency_job_id":null,"html_url":"https://github.com/skyhacker2/ECSegmentedControl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyhacker2%2FECSegmentedControl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyhacker2%2FECSegmentedControl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyhacker2%2FECSegmentedControl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyhacker2%2FECSegmentedControl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skyhacker2","download_url":"https://codeload.github.com/skyhacker2/ECSegmentedControl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227200344,"owners_count":17746902,"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":[],"created_at":"2024-11-29T19:37:12.660Z","updated_at":"2024-11-29T19:37:13.176Z","avatar_url":"https://github.com/skyhacker2.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\n\niOS的UISegmentedContorl控件在Android上的实现\n\n## Screenshot\n![image](./Screenshot.png)\n\n## Installation\n\n```\ndependencies {\n    compile 'com.eleven.lib:ecsegmentedcontrol:+'\n}\n```\n\n## Usage\n\n###默认样式：\n\n![image](./Screenshot2.png)\n\n```\n\u003ccom.eleven.lib.library.ECSegmentedControl\n    android:id=\"@+id/segmentedControl2\"\n    android:layout_marginTop=\"10dp\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    app:segmentedTexts=\"@array/segmentedTexts\"/\u003e\n```\n\n```\n\u003carray name=\"segmentedTexts\"\u003e\n    \u003citem\u003e经典\u003c/item\u003e\n    \u003citem\u003e摇滚\u003c/item\u003e\n    \u003citem\u003e爵士\u003c/item\u003e\n    \u003citem\u003e正常\u003c/item\u003e\n\u003c/array\u003e\n```\n\n默认使用colorPrimary颜色。\n\n### 自定义图片背景\n\n![image](./Screenshot3.png)\n\n```\n\u003ccom.eleven.lib.library.ECSegmentedControl\n    android:id=\"@+id/segmentedControl\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    app:textSize=\"13sp\"\n    app:segmentedBackground=\"@mipmap/ic_segmentedcontrol_bg\"\n    app:segmentedForeground=\"@mipmap/ic_segmentedcontrol_fg\"\n    app:textColor=\"@color/selector_sct1\"\n    app:segmentedTexts=\"@array/segmentedTexts\"\n    app:segmentedEnableDivider=\"true\"\n    app:segmentedDivider=\"@mipmap/ic_divider\"/\u003e\n```\n\n### 自定义颜色\n\n![image](./Screenshot4.png)\n\n```\n\u003ccom.eleven.lib.library.ECSegmentedControl\n    android:layout_marginTop=\"10dp\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    app:segmentedEnableDivider=\"true\"\n    app:textColor=\"@color/selector_sct2\"\n    app:segmentedDivider=\"@drawable/selector_segmented_divider\"\n    app:segmentedBackground=\"@drawable/selector_segmented_bg\"\n    app:segmentedForeground=\"@drawable/selector_segmented_fg\"/\u003e\n```\n\nselector_segmented_bg:\n\n```\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cshape xmlns:android=\"http://schemas.android.com/apk/res/android\" android:shape=\"rectangle\"\u003e\n    \u003cstroke android:color=\"@color/colorAccent\" android:width=\"3px\"/\u003e\n    \u003ccorners android:radius=\"5dp\"/\u003e\n\u003c/shape\u003e\n\n```\nselector_segmented_fg:\n\n```\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cshape xmlns:android=\"http://schemas.android.com/apk/res/android\" android:shape=\"rectangle\"\u003e\n    \u003csolid android:color=\"@color/colorAccent\"/\u003e\n    \u003ccorners android:radius=\"5dp\"/\u003e\n\u003c/shape\u003e\n```\nselector_segmented_divider:\n\n```\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cshape xmlns:android=\"http://schemas.android.com/apk/res/android\" android:shape=\"rectangle\"\u003e\n    \u003csolid android:color=\"@color/colorAccent\"/\u003e\n    \u003csize android:width=\"3px\"/\u003e\n\u003c/shape\u003e\n```\n\n\n### 事件监听\n\n```\nmSegmentedControl.setECSegmentedControlListener(new ECSegmentedControl.ECSegmentedControlListener() {\n    @Override\n    public void onSelectIndex(int index) {\n        Log.d(TAG, \"select index \" + index);\n    }\n});\n```\n\n选择选中的index\n\n```\nmSegmentedControl2.setSelectedIndex(2);\n```\n\n## Attributes\n\n```\n\u003cattr name=\"segmentedBackground\" format=\"reference\"/\u003e\n\u003cattr name=\"segmentedForeground\" format=\"reference\"/\u003e\n\u003cattr name=\"segmentedDivider\" format=\"reference\"/\u003e\n\u003cattr name=\"textSize\" format=\"dimension\"/\u003e\n\u003cattr name=\"textColor\" format=\"color\"/\u003e\n\u003cattr name=\"segmentedTexts\" format=\"reference\"/\u003e\n\u003cattr name=\"segmentedEnableDivider\" format=\"boolean\"/\u003e\n```\n\n## Author\n\nEleven Chen, skyhacker@126.com\n\n## License\n\nECSegmentedControl is available under the MIT license. See the LICENSE file for more info.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyhacker2%2Fecsegmentedcontrol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskyhacker2%2Fecsegmentedcontrol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyhacker2%2Fecsegmentedcontrol/lists"}