{"id":13643613,"url":"https://github.com/laobie/NineGridImageView","last_synced_at":"2025-04-21T02:30:48.450Z","repository":{"id":90174517,"uuid":"53183921","full_name":"laobie/NineGridImageView","owner":"laobie","description":"A custom widget for Android, which used for showing grid pictures.","archived":false,"fork":false,"pushed_at":"2019-04-15T05:21:48.000Z","size":202,"stargazers_count":1449,"open_issues_count":31,"forks_count":234,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-04-09T04:07:32.248Z","etag":null,"topics":["android","custom-widget","ninegridview","showing-grid-pictures"],"latest_commit_sha":null,"homepage":"http://t.cn/RGH3uNF","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/laobie.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}},"created_at":"2016-03-05T04:47:40.000Z","updated_at":"2025-03-20T07:50:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"122721b3-c1de-471a-b674-f24e5d3b02ab","html_url":"https://github.com/laobie/NineGridImageView","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/laobie%2FNineGridImageView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laobie%2FNineGridImageView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laobie%2FNineGridImageView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laobie%2FNineGridImageView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laobie","download_url":"https://codeload.github.com/laobie/NineGridImageView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249986033,"owners_count":21356311,"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":["android","custom-widget","ninegridview","showing-grid-pictures"],"created_at":"2024-08-02T01:01:50.146Z","updated_at":"2025-04-21T02:30:46.181Z","avatar_url":"https://github.com/laobie.png","language":"Java","readme":"# NineGridImageView\n\n[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)\n\n[中文版说明点我](http://laobie.github.io/android/2016/03/06/nine-grid-iamge-view-libaray.html)\n\nThis is a custom widget for Android, which uesd for showing grid pictures, such as you seeing in weibo or wechat.\n\n![](http://ac-qygvx1cc.clouddn.com/ee5906c846ad3346.png)\n\n### Update Log\n\n- 1.1.1\n  - add longClickListener method\n\n- 1.1.0\n  - modify `NineGridImageViewAdapter` 's  `onItemImageClick()` method, providing clicked ImageView\n  - add `setItemImageClickListener()` method\n\n+   1.0.3\n\n      fix return data not original bug\n\n+   1.0.2\n\n    + remove support library\n\n+   1.0.1 \n\n    + bug fix: if no image data or images size is zero, this view will not show;\n    + add set max size of images method;\n\n+   1.0.0 \n\n    first publish\n\n### Sample\n[Download NineGridImageView-Demo](http://fir.im/bkxn)\n\n### Features\n+ set gap between images\t\n\n  `app:imgGap=\"4dp\"` or `nineGridImageView.setGap(int gap);`\n\n  + set max size of images（）\n\n  `app:maxSize=\"9\"` or `nineGridImageView.setMaxSize(int maxSize);`\n\n  if `maxSize` Less than or equal to 0, there may not limit for images size.\n\n+ set style \n\n  `app:showStyle=\"fill\"` or `nineGridImageView.setShowStyle(int style);`\n\n  default style is `STYLE_GRID`:\n\n  ![](http://ac-qygvx1cc.clouddn.com/9cc94e97b4fce73f.png)\n\n  another style is `STYLE_FILL`:\n\n  ![](http://ac-qygvx1cc.clouddn.com/0fa728fd90d1b227.png)\n\n+ when only one image, you can set it's size by:\n\n  `app:singleImgSize=\"120dp\"` or `nineGridImageView.setSingleImgSize(int singleImgSize)`\n\n### Usage\n##### 1. Add the dependencies to your build.gradle file, NineGridImageView is avaiable in JCenter:\n\n\tcompile 'com.jaeger.ninegridimageview:library:1.1.1'\n\n##### 2. Add the NineGridImageView to your layout XML:\n\n~~~ xml\n\u003ccom.jaeger.ninegridimageview.NineGridImageView\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:layout_height=\"wrap_content\"\n    android:layout_margin=\"16dp\"\n    android:layout_width=\"match_parent\"\n    app:imgGap=\"4dp\"\n    app:showStyle=\"fill\"\n    app:singleImgSize=\"120dp\"/\u003e\n~~~\n\n##### 3. set a NineGridImageViewAdapter for NineGridImageView\n\n\tnineGridImageView.setAdapter(nineGridViewAdapter);\n\nHere is `NineGridImageViewAdapter.class` source code:\n​\t\n~~~ java\npublic abstract class NineGridImageViewAdapter\u003cT\u003e {\n\n    protected abstract void onDisplayImage(Context context, ImageView imageView, T t);\n\n    protected void onItemImageClick(Context context, ImageView imageView, int index, List\u003cT\u003e list) {\n    \n    }\n\n    protected ImageView generateImageView(Context context) {\n        GridImageView imageView = new GridImageView(context);\n        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);\n        return imageView;\n    }\n}\t\t\t\n~~~\n\n+ T is your image data model, you can simple use String or your own model\n+ you must override `onDisplayImage(Context context, ImageView imageView, T t)` method to set load image way, you can use Picasso, Glide or ImageLoader etc, and you can also set place holder for `ImageView`.\n+ if you need handle image click event, you can override `onItemImageClick(Context context, int index, List\u003cT\u003e list)` method, it is easy to handle image click event.\n+ if you want to customize ImageView, you can override `generateImageView(Context context)` method, to generate your custom `ImageView`.\n\nHere is sample code:\n​\t\n~~~ java\t\nprivate NineGridImageViewAdapter\u003cPhoto\u003e mAdapter = new NineGridImageViewAdapter\u003cPhoto\u003e() {\n\t@Override\n\tprotected void onDisplayImage(Context context, ImageView imageView, Photo photo) {\n\t\tPicasso.with(context)\n\t\t    .load(photo.getSmallUrl)\n\t\t    .placeholder(R.drawable.ic_default_image)\n\t\t    .into(imageView);\n    }\n\n    @Override\n    protected ImageView generateImageView(Context context) {\n        return super.generateImageView(context);\n    }\n\n    @Override\n    protected void onItemImageClick(Context context, ImageView imageView, int index, List\u003cPhoto\u003e photoList) {\n       showBigPicture(context, photoList.get(index).getBigUrl());\n    }\n};\n        \n...\n\tmNineGridImageView.setAdapter(mAdapter);\n...\n~~~\n\n##### 4. set pictures data for NineGridImageView\n~~~ java\nnineGridImageView.setImagesData(List\u003cT\u003e imageDataList);\n~~~\n\n##### 5. set ItemImageClickListener for NineGridImageView \n\n```java\nmNineImageView.setItemImageClickListener(new ItemImageClickListener\u003cString\u003e() {\n    @Override\n    public void onItemImageClick(Context context, ImageView imageView, int index, List\u003cString\u003e list) {\n\n    }\n});\n```\n\n\n\n### Credits\n\n- [panyiho/NineGridView](https://github.com/panyiho/NineGridView)\n- [w4lle/NineGridView](https://github.com/w4lle/NineGridView)\n\n### License\n\n\tCopyright 2016 Jaeger Chen\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\t\n\t\thttp://www.apache.org/licenses/LICENSE-2.0\n\t\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n\n\n​\t\n​\t \n​\t\t\n\n\n","funding_links":[],"categories":["Java","ImageView"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaobie%2FNineGridImageView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaobie%2FNineGridImageView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaobie%2FNineGridImageView/lists"}