{"id":13396094,"url":"https://github.com/linger1216/labelview","last_synced_at":"2026-01-05T03:57:56.923Z","repository":{"id":27287261,"uuid":"30760819","full_name":"linger1216/labelview","owner":"linger1216","description":"Sometimes, we need to show a label above an ImageView or any other views. Well, LabelView will be able to help you. It's easy to implement as well!","archived":false,"fork":false,"pushed_at":"2022-07-23T00:08:31.000Z","size":4048,"stargazers_count":1873,"open_issues_count":7,"forks_count":356,"subscribers_count":48,"default_branch":"master","last_synced_at":"2024-05-03T16:58:19.522Z","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/linger1216.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}},"created_at":"2015-02-13T14:56:41.000Z","updated_at":"2024-04-11T10:55:19.000Z","dependencies_parsed_at":"2022-08-31T21:34:20.447Z","dependency_job_id":null,"html_url":"https://github.com/linger1216/labelview","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linger1216%2Flabelview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linger1216%2Flabelview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linger1216%2Flabelview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linger1216%2Flabelview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linger1216","download_url":"https://codeload.github.com/linger1216/labelview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243493829,"owners_count":20299724,"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-07-30T18:00:39.908Z","updated_at":"2026-01-05T03:57:56.916Z","avatar_url":"https://github.com/linger1216.png","language":"Java","readme":"# LabelView\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-LabelView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/3/1538)\n\n\u003cbr /\u003e\n\nSometimes, we need to **show a label** above an ImageView or any other views. Well, **LabelXXView** will be able to help you. It's easy to implement as well!\n\n![](./img/img1.png)\n\n![](./img/img3.png)\n\n\n\n# Import your project\n\n#### Gradle\n\n**Step 1.** Add the JitPack repository to your build file\n\nAdd it in your **root build.gradle** at the end of repositories:\n\n```\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url \"https://jitpack.io\" }\n\t}\n}\n```\n\n\u003cbr /\u003e\n\n**Step 2.** Add the dependency\n\n```\ndependencies {\n\tcompile 'com.github.linger1216:labelview:v1.1.2'\n}\n```\n\n\u003cbr /\u003e\n\n#### Or Manual\n\nCopy all `java files` and `attr.xml` into your project.\n\n\u003cbr /\u003e\n\n# Create a Label\n\n\n\nput xml code in you layout, like follows.\n\n\n\n## LabelButtonView\n\n\n\n```java\n\u003ccom.lid.lib.LabelButtonView\n    android:id=\"@+id/labelbutton\"\n    android:layout_width=\"200dp\"\n    android:layout_height=\"48dp\"\n    android:background=\"#03a9f4\"\n    android:gravity=\"center\"\n    android:text=\"Button\"\n    android:textColor=\"#ffffff\"\n    app:label_backgroundColor=\"#C2185B\"\n    app:label_distance=\"20dp\"\n    app:label_height=\"20dp\"\n    app:label_orientation=\"RIGHT_TOP\"\n    app:label_text=\"HD\"\n    app:label_textSize=\"12sp\" /\u003e\n```\n\n\n\n## LabelImageView\n\n\n\n```\n\u003ccom.lid.lib.LabelImageView\n    android:id=\"@+id/image1\"\n    android:layout_width=\"0dp\"\n    android:layout_height=\"match_parent\"\n    android:layout_weight=\"1\"\n    android:scaleType=\"centerCrop\"\n    android:src=\"@mipmap/image1\"\n    app:label_backgroundColor=\"#C2185B\"\n    app:label_orientation=\"LEFT_TOP\"\n    app:label_text=\"CHINA\" /\u003e\n```\n\n\n\n\n\n## LabelTextView\n\n\n\n```\n\u003ccom.lid.lib.LabelTextView\n    android:id=\"@+id/text\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"48dp\"\n    android:layout_gravity=\"center\"\n    android:layout_marginTop=\"8dp\"\n    android:background=\"#212121\"\n    android:gravity=\"center\"\n    android:padding=\"16dp\"\n    android:text=\"TextView\"\n    android:textColor=\"#ffffff\"\n    app:label_backgroundColor=\"#03A9F4\"\n    app:label_distance=\"15dp\"\n    app:label_orientation=\"LEFT_TOP\"\n    app:label_text=\"POP\"\n    app:label_textSize=\"10sp\" /\u003e\n```\n\n\n\n\n\n# Parameter Description\n\n![](./img/img2.png)\n\n\n\n# If you need Label in your custom View\n\n\n\n1. create an new view class extends `YourView`\n2. use LabelViewHelper as your `Member objects`\n3. In Constructor function and onDraw function call LabelViewHelper method.\n4. Call the LabelViewHelper method in other functions\n\nlike as follows:\n\n```java\npublic class LabelXXXView extends YourView {\n    LabelViewHelper utils;\n    public LabelXXXView(Context context) {\n        this(context, null);\n    }\n    public LabelXXXView(Context context, AttributeSet attrs) {\n        this(context, attrs, 0);\n    }\n    public LabelXXXView(Context context, AttributeSet attrs, int defStyleAttr) {\n        super(context, attrs, defStyleAttr);\n        utils = new LabelViewHelper(context, attrs, defStyleAttr);\n    }\n    @Override\n    protected void onDraw(Canvas canvas) {\n        super.onDraw(canvas);\n        utils.onDraw(canvas, getMeasuredWidth(), getMeasuredHeight());\n    }\n    public void setLabelHeight(int height) {\n        utils.setLabelHeight(this, height);\n    }\n    public int getLabelHeight() {\n        return utils.getLabelHeight();\n    }\n    public void setLabelDistance(int distance) {\n        utils.setLabelDistance(this, distance);\n    }\n    public int getLabelDistance() {\n        return utils.getLabelDistance();\n    }\n    public boolean isLabelVisual() {\n        return utils.isLabelVisual();\n    }\n    public void setLabelVisual(boolean enable) {\n        utils.setLabelVisual(this, enable);\n    }\n    public int getLabelOrientation() {\n        return utils.getLabelOrientation();\n    }\n    public void setLabelOrientation(int orientation) {\n      \tutils.setLabelOrientation(this, orientation);\n    }\n    public int getLabelTextColor() {\n        return utils.getLabelTextColor();\n    }\n    public void setLabelTextColor(int textColor) {\n        utils.setLabelTextColor(this, textColor);\n    }\n    public int getLabelBackgroundColor() {\n        return utils.getLabelBackgroundColor();\n    }\n    public void setLabelBackgroundColor(int backgroundColor) {\n      \tutils.setLabelBackgroundColor(this, backgroundColor);\n    }\n    public String getLabelText() {\n        return utils.getLabelText();\n    }\n    public void setLabelText(String text) {\n        utils.setLabelText(this, text);\n    }\n    public int getLabelTextSize() {\n        return utils.getLabelTextSize();\n    }\n    public void setLabelTextSize(int textSize) {\n        utils.setLabelTextSize(this, textSize);\n    }\n}\n```\n\n\n\n\n\n\n\n\n\n# Thanks\n\n- [shaunidiot](https://github.com/shaunidiot) English ReadMe supported\n\n## License\n\n```\nCopyright 2014 linger1216\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\nhttp://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```\n","funding_links":[],"categories":["Index `(light-weight pages)`","Label","Index","Java"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinger1216%2Flabelview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinger1216%2Flabelview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinger1216%2Flabelview/lists"}