{"id":13644333,"url":"https://github.com/paulyung541/LaybelLayout","last_synced_at":"2025-04-21T07:30:58.777Z","repository":{"id":144242665,"uuid":"73057821","full_name":"paulyung541/LaybelLayout","owner":"paulyung541","description":"自动换行布局 标签布局","archived":false,"fork":false,"pushed_at":"2017-07-05T01:34:06.000Z","size":268,"stargazers_count":52,"open_issues_count":2,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-02T01:22:43.234Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulyung541.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-07T08:33:52.000Z","updated_at":"2023-05-16T02:42:17.000Z","dependencies_parsed_at":"2024-01-14T11:17:13.858Z","dependency_job_id":"09ab5c7e-584a-43ce-b593-cec0d0d14000","html_url":"https://github.com/paulyung541/LaybelLayout","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulyung541%2FLaybelLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulyung541%2FLaybelLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulyung541%2FLaybelLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulyung541%2FLaybelLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulyung541","download_url":"https://codeload.github.com/paulyung541/LaybelLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223853471,"owners_count":17214469,"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-08-02T01:02:01.424Z","updated_at":"2024-11-09T16:32:14.571Z","avatar_url":"https://github.com/paulyung541.png","language":"Java","funding_links":[],"categories":["TagView"],"sub_categories":[],"readme":"# LaybelLayout\n这是一个可以根据内容自动换行的标签布局\n\n原理剖析请看http://www.jianshu.com/p/82f0053b8726\u003c/br\u003e\n\n![image](https://github.com/paulyung541/LaybelLayout/blob/master/pic/demo1.jpg)\n![image](https://github.com/paulyung541/LaybelLayout/blob/master/pic/demo2.jpg)\n![image](https://github.com/paulyung541/LaybelLayout/blob/master/pic/demo3.jpg)\n\n##添加依赖\n在Projectd的gradle文件里添加如下：\n```groovy\nmaven { url 'https://jitpack.io' }\n```\n在项目主Module里添加如下：\n```groovy\ncompile 'com.github.paulyung541:LaybelLayout:v1.2.0'\n```\n\n\n自定义属性：\n```xml\napp:line_padding=\"Integer\" \u003c!-- 表示每一行的上下内边距 --\u003e\napp:text_background=\"reference\" \u003c!-- 表示TextView的自定义背景 --\u003e\n```\n\n## 示例\n在xml里面添加该控件\n```xml\n\u003ccom.paulyung.laybellayout.LaybelLayout\n        android:id=\"@+id/laybel_layout\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:padding=\"5dp\"\n        app:text_background=\"@drawable/custom_back\"\n        app:line_padding=\"5\"/\u003e\n```\n\n设置Adapter提供数据\u003cbr\u003e\n**Note：** 这个Adapter可不是ListView的Adapter哦，是自己定义的，不过用法差不多\n```java\nlaybelLayout = (LaybelLayout) findViewById(R.id.laybel_layout);\nlaybelLayout.setAdapter(new LaybelLayout.Adapter(Content.content));\n```\n\n如果要使用其它子View，比如ImageView，则需要重写`Adapter.getView()`方法\n```java\nlaybelLayout = (LaybelLayout) findViewById(R.id.laybelLayout);\nlaybelLayout.setAdapter(new LaybelLayout.Adapter(Content.images) {\n    @Override\n    public View getView() {\n        ImageView imageView = new ImageView(ImageActivity.this);\n        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);\n        ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(getWidth() / 3, getWidth() / 3);\n        imageView.setLayoutParams(params);\n        return imageView;\n    }\n\n    @Override\n    public void onDataSet(View v, String data) {\n        Glide.with(ImageActivity.this).load(data).into((ImageView) v);\n    }\n});\n```\n添加点击事件\n```java\nlaybelLayout.setOnItemClickListener(new LaybelLayout.OnItemClickListener() {\n    @Override\n    public void onItemClick(int p) {\n        Toast.makeText(DefaultTextViewActivity.this, Content.content[p], Toast.LENGTH_SHORT).show();\n    }\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulyung541%2FLaybelLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulyung541%2FLaybelLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulyung541%2FLaybelLayout/lists"}