{"id":13642394,"url":"https://github.com/czy1121/loadinglayout","last_synced_at":"2025-04-20T16:32:12.830Z","repository":{"id":199057611,"uuid":"75157785","full_name":"czy1121/loadinglayout","owner":"czy1121","description":"简单实用的页面多状态布局(content,loading,empty,error) ","archived":true,"fork":false,"pushed_at":"2020-06-08T06:01:33.000Z","size":176,"stargazers_count":752,"open_issues_count":15,"forks_count":110,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-08-03T01:26:19.376Z","etag":null,"topics":["content","empty","error","loading","status"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/czy1121.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}},"created_at":"2016-11-30T06:21:26.000Z","updated_at":"2024-06-24T08:50:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"6452a2a3-a434-44c1-8b39-8ee09608a27c","html_url":"https://github.com/czy1121/loadinglayout","commit_stats":null,"previous_names":["czy1121/loadinglayout"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czy1121%2Floadinglayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czy1121%2Floadinglayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czy1121%2Floadinglayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czy1121%2Floadinglayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/czy1121","download_url":"https://codeload.github.com/czy1121/loadinglayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223833036,"owners_count":17210763,"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":["content","empty","error","loading","status"],"created_at":"2024-08-02T01:01:30.858Z","updated_at":"2024-11-09T13:31:42.801Z","avatar_url":"https://github.com/czy1121.png","language":"Java","readme":"# LoadingLayout [![](https://jitpack.io/v/czy1121/loadinglayout.svg)](https://jitpack.io/#czy1121/loadinglayout)\n \n简单实用的页面多状态布局(content,loading,empty,error)  \n \n\n![loadinglayout1](screenshot1.png) ![loadinglayout2](screenshot2.png)\n\n## Gradle\n\n``` groovy\nrepositories { \n    maven { url \"https://jitpack.io\" }\n} \ndependencies {\n    compile 'com.github.czy1121:loadinglayout:1.0.1'\n}\n```\n    \n## Usage \n\n**在主题中设置默认样式**\n\n``` xml \n\u003cstyle name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\"\u003e\n    ...\n    \u003citem name=\"styleLoadingLayout\"\u003e@style/LoadingLayoutStyle\u003c/item\u003e\n\u003c/style\u003e\n\n\u003cstyle name=\"LoadingLayoutStyle\" parent=\"LoadingLayout.Style\"\u003e\n    \u003citem name=\"llEmptyImage\"\u003e@mipmap/empty\u003c/item\u003e\n    \u003citem name=\"llErrorImage\"\u003e@mipmap/error\u003c/item\u003e\n    ...\n\u003c/style\u003e\n```\n\n**用法一：在布局中使用**\n\n``` xml  \n\u003cezy.ui.layout.LoadingLayout\n    android:id=\"@+id/loading\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n    \u003cTextView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:gravity=\"center\"\n        android:text=\"This is Content\"/\u003e\n        \n\u003c/ezy.ui.layout.LoadingLayout\u003e\n \n``` \n\n**用法二：包裹并替换内容元素**\n\n``` java   \n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_main);\n    \n    // ...\n    \n    vLoading = LoadingLayout.wrap(this); \n    vLoading.showContent(); \n    \n    // ...\n}\n``` \n**API**\n\n``` java\n// 显示 content/loading/empty/error 布局\nshowContent()\nshowLoading()\nshowEmpty()\nshowError()\n\n// 设置 loading/empty/error 布局\nsetLoading(int resId)\nsetEmpty(int resId)\nsetError(int resId)\n\n// 设置空布局的图片与文本\nsetEmptyImage(int resId)\nsetEmptyText(String value)\n\n// 设置错误布局的图片与文本，\nsetErrorImage(int resId)\nsetErrorText(String value) \n\n// 设置重试按钮文本\nsetRetryText(String value)\n\n// 设置重试按钮的监听回调\nsetRetryListener(OnClickListener listener)\n\n```\n\n**属性**\n\n``` xml  \n\u003cdeclare-styleable name=\"LoadingLayout\"\u003e\n    \u003c!-- 空布局资源id --\u003e\n    \u003cattr name=\"llEmptyResId\" format=\"reference\"/\u003e\n    \u003c!-- 加载中布局资源id --\u003e\n    \u003cattr name=\"llLoadingResId\" format=\"reference\"/\u003e\n    \u003c!-- 错误布局资源id --\u003e\n    \u003cattr name=\"llErrorResId\" format=\"reference\"/\u003e\n\n    \u003c!-- 空布局图片 --\u003e\n    \u003cattr name=\"llEmptyImage\" format=\"reference\"/\u003e\n    \u003c!-- 空布局文本 --\u003e\n    \u003cattr name=\"llEmptyText\" format=\"string\"/\u003e\n\n    \u003c!-- 错误布局图片 --\u003e\n    \u003cattr name=\"llErrorImage\" format=\"reference\"/\u003e\n    \u003c!-- 错误布局文本 --\u003e\n    \u003cattr name=\"llErrorText\" format=\"string\"/\u003e\n    \u003c!-- 错误布局重试按钮文本 --\u003e\n    \u003cattr name=\"llRetryText\" format=\"string\"/\u003e\n\n    \u003c!-- 文本颜色 --\u003e\n    \u003cattr name=\"llTextColor\" format=\"color\"/\u003e\n    \u003c!-- 文本尺寸 --\u003e\n    \u003cattr name=\"llTextSize\" format=\"dimension\"/\u003e\n\n    \u003c!-- 按钮文本颜色 --\u003e\n    \u003cattr name=\"llButtonTextColor\" format=\"color\"/\u003e\n    \u003c!-- 按钮文本尺寸 --\u003e\n    \u003cattr name=\"llButtonTextSize\" format=\"dimension\"/\u003e\n    \u003c!-- 按钮背景 --\u003e\n    \u003cattr name=\"llButtonBackground\" format=\"reference\"/\u003e\n\u003c/declare-styleable\u003e\n``` \n\n\n \n\n## License\n\n```\nCopyright 2016 czy1121\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```","funding_links":[],"categories":["空白页"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczy1121%2Floadinglayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fczy1121%2Floadinglayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczy1121%2Floadinglayout/lists"}