{"id":17688212,"url":"https://github.com/ccapton/android-pagerindicator","last_synced_at":"2025-03-30T21:28:04.481Z","repository":{"id":176302367,"uuid":"79202351","full_name":"Ccapton/Android-PagerIndicator","owner":"Ccapton","description":"这是一个ViewPager指示器，背景颜色、标题颜色字体大小可自由设置，指示滑块厚度、宽度与颜色也可自由设置","archived":false,"fork":false,"pushed_at":"2017-08-15T13:12:34.000Z","size":638,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-06T01:41:23.540Z","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/Ccapton.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-17T07:47:48.000Z","updated_at":"2019-09-30T08:21:32.000Z","dependencies_parsed_at":"2023-06-29T21:31:17.780Z","dependency_job_id":null,"html_url":"https://github.com/Ccapton/Android-PagerIndicator","commit_stats":null,"previous_names":["ccapton/android-pagerindicator"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ccapton%2FAndroid-PagerIndicator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ccapton%2FAndroid-PagerIndicator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ccapton%2FAndroid-PagerIndicator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ccapton%2FAndroid-PagerIndicator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ccapton","download_url":"https://codeload.github.com/Ccapton/Android-PagerIndicator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246382633,"owners_count":20768242,"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-10-24T11:43:47.739Z","updated_at":"2025-03-30T21:28:04.453Z","avatar_url":"https://github.com/Ccapton.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PagerIndicator \n\u003e 关于我，欢迎关注  \n  博客：ccapton(http://blog.csdn.net/ccapton) 微信：[Ccapton]()   \n \n### 简介: \n\n这是一个ViewPager的指示器。当页面滑动时，指示器也会跳转到其相应的选项去；点击选项，ViewPager也会跳转到相应页面。\n\n### 效果:   \n![](https://raw.githubusercontent.com/Ccapton/pagerIndicator/master/indicator.gif)\n\n### 如何配置\nbuild.gradle(Project)\n``` code\nallprojects {\n\t\trepositories {\n\t\t\t...\n\t\t\tmaven { url 'https://jitpack.io' }\n\t\t}\n\t}\n```\nbuild.gradle(Module:app)\n``` code \n dependencies {\n\t        compile 'com.github.Ccapton:PagerIndicator:1.2'\n\t}\n```\n\n### 公共方法\n``` code\n  **为必须要先调用的方法\n   \n  setViewPager(ViewPager viewPager);//将要绑定的viewpager对象传进PagerIndicator对象中，供其调用。 **\n  setTitleList(List\u003cString\u003e titleList) //设置标题的字符串ArrayList                               **\n  setTextCheckedColor(int textCheckedColor) //设置标题选中时字体的颜色\n \tsetTextColor(int textColor)   //设置标题的字体颜色\n \tsetTextSize(int textSize)      //设置标题的字体大小\n  setLineColor(int lineColor)    //设置横线的颜色\n \tsetLineHeight(int lineHeight)  //设置横线的厚度（高度）\n \tsetLineProportion(float lineProportion) //设置横线占标题宽度的比例（宽度）：0.0~1.0\n```\n\t\n### 使用方法\n 1.例如：在activity_main.xml中,把该自定义控件PagerIndicator写在目标ViewPager前面\n``` xml\n \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n \u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:id=\"@+id/activity_main\"\n    android:orientation=\"vertical\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:paddingBottom=\"@dimen/activity_vertical_margin\"\n    android:background=\"#80bebebe\"\n    tools:context=\"chen.capton.demo.MainActivity\"\u003e\n\n    \u003c!--默认样式default--\u003e\n     \u003cchen.capton.custom.PagerIndicator\n         xmlns:indicator=\"http://schemas.android.com/apk/res-auto\"\n         android:id=\"@+id/indicator\"\n         android:layout_width=\"match_parent\"\n         android:layout_height=\"wrap_content\"/\u003e\n    \u003candroid.support.v4.view.ViewPager\n        android:id=\"@+id/viewpager\"\n        android:background=\"#fff\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"200dp\"\u003e\n    \u003c/android.support.v4.view.ViewPager\u003e\n    \n     \u003c!--自定义样式custom--\u003e\n    \u003cchen.capton.custom.PagerIndicator\n        xmlns:indicator=\"http://schemas.android.com/apk/res-auto\"\n        android:layout_marginTop=\"@dimen/activity_vertical_margin\"\n        android:background=\"@color/colorPrimary\"\n        android:id=\"@+id/indicator2\"\n        indicator:textColor=\"#fff\"  //设置标题的字体颜色\n        indicator:textCheckedColor=\"#03eC19\" //设置标题选中时字体的颜色\n        indicator:textSize=\"12sp\"    //设置标题的字体大小\n        indicator:lineColor=\"#03eC19\"  //设置横线的颜色\n        indicator:lineProportion=\"1\"   //设置横线占标题宽度的比例（宽度）：0.0~1.0\n        indicator:lineHeight=\"12dp\"    //设置横线的厚度（高度）\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"50dp\"/\u003e\n    \u003candroid.support.v4.view.ViewPager\n        android:id=\"@+id/viewpager2\"\n        android:background=\"#fff\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"200dp\"\u003e\n    \u003c/android.support.v4.view.ViewPager\u003e\n    \u003c/LinearLayout\u003e\n```\n  2.在代码中findViewById获取PagerIndicator对象，然后调用其公共方法（上文提到了）。例如下面的例子：\n ``` code\n  @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        viewPager= (ViewPager) findViewById(R.id.viewpager);\n        ...省略代码...\n        viewPager.setAdapter(adapter);\n        indicator= (PagerIndicator) findViewById(R.id.indicator);\n        indicator2= (PagerIndicator) findViewById(R.id.indicator2);\n        indicator.setTitleList(titleList); //设置标题字符串ArrayList, 首先调用\n        indicator.setViewPager(viewPager);  //设置目标ViewPager对象， 第二调用\n        indicator.setTextColor(R.color.pager_indicator_black); /设置标题的字体颜色\n        indicator.setTextSize(12);   //设置标题的字体大小\n        indicator.setTextCheckedColor(R.color.pager_indicator_white); //设置标题选中时字体的颜色\n        indicator.setLineHeight(12); //设置横线的厚度（高度）\n        indicator.setLineColor(R.color.pager_indicator_white); //设置横线的颜色\n        indicator.setLineProportion(0.8f); //设置横线占标题宽度的比例（宽度）：0.0~1.0\n        //也可以链式调用\n        // indicator.setTitleList(titleList).setViewPager(viewPager).setTextSize(12).setLineHeight(12)...;\n        } \n ```\n### 作者的话\n 一个诚意满满的作品，哈哈，欢迎大家采纳，源码仅供参考。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccapton%2Fandroid-pagerindicator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccapton%2Fandroid-pagerindicator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccapton%2Fandroid-pagerindicator/lists"}