{"id":19793238,"url":"https://github.com/wuyr/litepager","last_synced_at":"2025-04-05T14:07:58.865Z","repository":{"id":109150360,"uuid":"179438725","full_name":"wuyr/LitePager","owner":"wuyr","description":"LitePager，一个轻量级的ViewPager，仿新版网易云歌单广场","archived":false,"fork":false,"pushed_at":"2020-04-12T09:54:49.000Z","size":23550,"stargazers_count":626,"open_issues_count":9,"forks_count":56,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T13:09:40.445Z","etag":null,"topics":["scale","vertical","viewpager"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wuyr.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-04T06:50:25.000Z","updated_at":"2025-03-24T02:47:24.000Z","dependencies_parsed_at":"2023-06-15T04:15:31.045Z","dependency_job_id":null,"html_url":"https://github.com/wuyr/LitePager","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/wuyr%2FLitePager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuyr%2FLitePager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuyr%2FLitePager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuyr%2FLitePager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wuyr","download_url":"https://codeload.github.com/wuyr/LitePager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345853,"owners_count":20924102,"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":["scale","vertical","viewpager"],"created_at":"2024-11-12T07:09:16.450Z","updated_at":"2025-04-05T14:07:58.845Z","avatar_url":"https://github.com/wuyr.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"##  LitePager，一个轻量级的ViewPager，仿新版网易云歌单广场\n### 博客详情： \u003chttps://blog.csdn.net/u011387817/article/details/89142467\u003e\n\n### 使用方式:\n#### 添加依赖：\n```\nimplementation 'com.wuyr:litepager:1.3.1'\n```\n\n### APIs:\n|Method|Description|\n|------|-----------|\n|addViews(int... layouts)|批量添加子View|\n|addViews(View... views)|批量添加子View|\n|setSelection(View target)|选中指定子View|\n|setSelection(int index)|根据索引选中子View|\n|setOrientation(int orientation)|设置滑动方向(默认: ORIENTATION_HORIZONTAL):\u003cbr\u003e**ORIENTATION_HORIZONTAL**(水平)\u003cbr\u003e**ORIENTATION_VERTICAL**(垂直)|\n|setFlingDuration(long duration)|设置动画的时长|\n|setTopScale(float scale)|设置**顶层**缩放比例|\n|setTopAlpha(float alpha)|设置**顶层**不透明度|\n|setMiddleScale(float scale)|设置**中层**缩放比例|\n|setMiddleAlpha(float alpha)|设置**中层**不透明度|\n|setBottomScale(float scale)|设置**底层**缩放比例|\n|setBottomAlpha(float alpha)|设置**底层**不透明度|\n|setOnScrollListener(OnScrollListener listener)|设置滚动状态监听:\u003cbr\u003e**STATE_IDLE**(静止状态)\u003cbr\u003e**STATE_DRAGGING_LEFT**(向左拖动)\u003cbr\u003e**STATE_DRAGGING_RIGHT**(向右拖动)\u003cbr\u003e**STATE_DRAGGING_TOP**(向上拖动)\u003cbr\u003e**STATE_DRAGGING_BOTTOM**(向下拖动)\u003cbr\u003e**STATE_SETTLING_LEFT**(向左调整)\u003cbr\u003e**STATE_SETTLING_RIGHT**(向右调整)\u003cbr\u003e**STATE_SETTLING_TOP**(向上调整)\u003cbr\u003e**STATE_SETTLING_BOTTOM**(向下调整)\u003cbr\u003e|\n|setOnItemSelectedListener(SelectedListener listener) |设置子View被选中的监听|\n|getSelectedChild() |获取当前选中的子View|\n|setAutoScrollEnable(boolean enable) |设置是否开启自动轮播 (默认: false)|\n|setAutoScrollInterval(long interval) |设置自动轮播的间隔 (默认: 5000 ms)|\n|setAutoScrollOrientation(int orientation) |设置自动轮播的方向(默认: SCROLL_ORIENTATION_LEFT):\u003cbr\u003e**SCROLL_ORIENTATION_LEFT**(向左滚动)\u003cbr\u003e**SCROLL_ORIENTATION_RIGHT**(向右滚动)\u003cbr\u003e**SCROLL_ORIENTATION_UP**(向上滚动)\u003cbr\u003e**SCROLL_ORIENTATION_DOWN**(向下滚动)\u003cbr\u003e|\n|setAdapter(Adapter adapter)|使用Adapter来添加子View(见下)|\n\n### Attributes:\n|Name|Format|Description|\n|----|-----|-----------|\n|orientation|enum (默认: horizontal)\u003cbr\u003e**horizontal**(水平)\u003cbr\u003e**vertical**(垂直)|滑动方向|\n|flingDuration|integer|动画时长|\n|topScale|float (默认: 1)|**顶层**缩放比例|\n|topAlpha|float (默认: 1)|**顶层**不透明度|\n|middleScale|float (默认: 0.8)|**中层**缩放比例|\n|middleAlpha|float (默认: 0.4)|**中层**不透明度|\n|bottomScale|float (默认: 0.6)|**底层**缩放比例|\n|bottomAlpha|float (默认: 0.2)|**底层**不透明度|\n|autoScroll|boolean (默认: false)|是否开启自动轮播|\n|autoScrollInterval|float (默认: 5000)|自动轮播的间隔|\n|autoScrollOrientation|enum (默认: left)\u003cbr\u003e**left**(向左滚动)\u003cbr\u003e**right**(向右滚动)\u003cbr\u003e**up**(向上滚动)\u003cbr\u003e**down**(向下滚动)|自动轮播的方向|\n\n### 添加子View方式：\n#### 1. XML\n\n```xml\n    \u003ccom.wuyr.litepager.LitePager\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\u003e\n\n        \u003cView\n            android:layout_width=\"150dp\"\n            android:layout_height=\"200dp\"\n            android:background=\"#F00\" /\u003e\n\n        \u003cView\n            android:layout_width=\"150dp\"\n            android:layout_height=\"200dp\"\n            android:background=\"#0F0\"/\u003e\n\n        \u003cView\n            android:layout_width=\"150dp\"\n            android:layout_height=\"200dp\"\n            android:background=\"#00F\"/\u003e\n    \u003c/com.wuyr.litepager.LitePager\u003e\n```\n\n#### 2. 批量添加\n\n```java\n    LitePager litePager = ...;\n    View child1 = ...;\n    View child2 = ...;\n    View child3 = ...;\n\n    litePager.addViews(child1, child2, child3);\n```\n\n#### 3. 通过布局添加\n```java\n    litePager.addViews(\n        R.layout.view_child1 \n        R.layout.view_child2,\n        R.layout.view_child3\n    );\n```\n\n#### 4. 设置适配器\n**示例：**\nItem布局：\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cFrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"200dp\"\n    android:layout_height=\"250dp\"\n    android:background=\"@color/colorPrimary\"\u003e\n\n    \u003cTextView\n        android:id=\"@+id/text\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"center\"\n        android:textSize=\"30sp\" /\u003e\n\u003c/FrameLayout\u003e\n```\nJava代码：\n```java\nlitePager.setAdapter(new Adapter\u003cViewGroup\u003e() {\n\n    private List\u003cString\u003e mData = new ArrayList\u003c\u003e(Arrays.asList(\"Item 1\", \"Item2\", \"Item3\"));\n\n    @Override\n    protected ViewGroup onCreateView(@NonNull ViewGroup parent) {\n        return (ViewGroup) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_view, parent, false);\n    }\n\n    @Override\n    protected void onBindView(@NonNull ViewGroup viewGroup, int position) {\n        TextView textView = viewGroup.findViewById(R.id.text);\n        textView.setText(mData.get(position));\n    }\n\n    @Override\n    protected int getItemCount() {\n        return mData.size();\n    }\n});\n```\n\n\u003cbr\u003e\n\n### Demo下载: [app-debug.apk](https://github.com/wuyr/LitePager/raw/master/app-debug.apk)\n### 库源码地址： \u003chttps://github.com/Ifxcyr/LitePager\u003e\n\n### 效果 (图1为网易云原效果)：\n![preview](https://github.com/wuyr/LitePager/raw/master/previews/preview1.gif) ![preview](https://github.com/wuyr/LitePager/raw/master/previews/preview2.gif)\n![preview](https://github.com/wuyr/LitePager/raw/master/previews/preview3.gif) ![preview](https://github.com/wuyr/LitePager/raw/master/previews/preview4.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwuyr%2Flitepager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwuyr%2Flitepager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwuyr%2Flitepager/lists"}