{"id":13639575,"url":"https://github.com/hluhovskyi/HoldingButton","last_synced_at":"2025-04-19T22:33:07.870Z","repository":{"id":93973718,"uuid":"84426965","full_name":"hluhovskyi/HoldingButton","owner":"hluhovskyi","description":"Button which is visible while user holds it. Main use case is controlling audio recording state (like in Telegram, Viber, VK). ","archived":false,"fork":false,"pushed_at":"2018-10-21T16:51:52.000Z","size":2342,"stargazers_count":597,"open_issues_count":9,"forks_count":72,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-05-22T06:10:39.091Z","etag":null,"topics":["android-library","button","java","material-design","ui"],"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/hluhovskyi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2017-03-09T10:03:40.000Z","updated_at":"2024-03-31T03:53:50.000Z","dependencies_parsed_at":"2023-04-10T02:49:09.928Z","dependency_job_id":null,"html_url":"https://github.com/hluhovskyi/HoldingButton","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hluhovskyi%2FHoldingButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hluhovskyi%2FHoldingButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hluhovskyi%2FHoldingButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hluhovskyi%2FHoldingButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hluhovskyi","download_url":"https://codeload.github.com/hluhovskyi/HoldingButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223502361,"owners_count":17155938,"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-library","button","java","material-design","ui"],"created_at":"2024-08-02T01:01:02.223Z","updated_at":"2024-11-09T09:31:13.436Z","avatar_url":"https://github.com/hluhovskyi.png","language":"Java","funding_links":[],"categories":["按钮"],"sub_categories":[],"readme":"# HoldingButton\n\n\u003ca href=\"http://www.methodscount.com/?lib=com.dewarder%3Aholdingbutton%3A0.0.5\"\u003e\u003cimg src=\"https://img.shields.io/badge/Size-22 KB-e91e63.svg\"/\u003e\u003c/a\u003e \u003ca href=\"http://www.methodscount.com/?lib=com.dewarder%3Aholdingbutton%3A0.0.5\"\u003e\u003cimg src=\"https://img.shields.io/badge/Methods count-core: 249 | deps: 32-e91e63.svg\"/\u003e\u003c/a\u003e [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-HoldingButton-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5436)\n\nButton which is visible while user holds it. Main use case is controlling audio recording state (like in Telegram, Viber, VK). \n\n\u003cimg src=\"/_arts/example.gif\" width=\"300\" height=\"533\"/\u003e\n\n## Getting started\n\nAdd library as dependency to your `build.gradle`.\n\n```\ncompile 'com.dewarder:holdingbutton:0.1.3'\n```\n\n## How to use\n\n1. Wrap your layout with `HoldingButtonLayout`. It is simple `FrameLayout` inside.\n\n   ```xml\n    \u003ccom.dewarder.holdinglibrary.HoldingButtonLayout\n        android:id=\"@+id/input_holder\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\u003e\n        \n        ...\n     \n        \u003cImageView\n            android:id=\"@+id/start_record\"\n            android:layout_width=\"48dp\"\n            android:layout_height=\"match_parent\"\n            android:scaleType=\"center\"\n            android:src=\"@drawable/ic_mic_black_24dp\"/\u003e\n\n        ...\n \n    \u003c/com.dewarder.holdinglibrary.HoldingButtonLayout\u003e\n\n    ```\n\n2. Set `app:hbl_holding_view` property to id of view which would be translated to `HoldingButton`\n\n   ```xml\n    \u003ccom.dewarder.holdinglibrary.HoldingButtonLayout\n        android:id=\"@+id/input_holder\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        app:hbl_holding_view=\"@+id/start_record\"\u003e\n   ```\n\n3. Set `app:hbl_icon` property to icon (usually it is the same as in translated view) which would be appeared in `HoldingButton`.\n\n   ```xml\n    \u003ccom.dewarder.holdinglibrary.HoldingButtonLayout\n        android:id=\"@+id/input_holder\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        app:hbl_holding_view=\"@+id/start_record\"\n        app:hbl_icon=\"@drawable/ic_mic_black_24dp\"\u003e\n   ```\n\n4. Listen events\n\n   ```java\n   \n   mHoldingButtonLayout.addListener(new SimpleHoldingButtonLayoutListener() {\n       @Override\n       public void onOffsetChanged(float offset, boolean isCancel) {\n           mSlideToCancel.setTranslationX(-mHoldingButtonLayout.getWidth() * offset);\n           mSlideToCancel.setAlpha(1 - SLIDE_TO_CANCEL_ALPHA_MULTIPLIER * offset);\n       }\n   });\n   \n   ```\n\n5. Enjoy!\n\n   ![Check full example](https://github.com/dewarder/HoldingButton/tree/master/holdingbuttonsample)\n\n## All XML properties\n\n- `hbl_enabled` (`isButtonEnabled/setButtonEnabled`)\n\n   Set enabled or disabled state of button only.\n\n- `hbl_direction` (`getDirection/setDirection`)\n\n   Set direction of sliding. Possible directions are `start` (from right to left) and `end` (from left to right).\n\n   ![](/_arts/hbl_directions.png)\n\n- `hbl_cancel_offset` (`getCancelOffset/setCancelOffset`)\n\n   Set minimum offset for cancel action.\n\n   ![](/_arts/hbl_cancel_offset.png)\n\n- `hbl_icon` (`setIcon`)\n\n   ![](/_arts/hbl_icon.png)\n\n- `hbl_cancel_icon` (`setCancelIcon`)\n\n   ![](/_arts/hbl_cancel_icon.png)\n\n- `hbl_color` (`getColor/setColor`)\n\n   ![](/_arts/hbl_color.png)\n\n- `hbl_cancel_color` (`getCancelColor/CancelColor`)\n\n   ![](/_arts/hbl_cancel_color.png)\n\n- `hbl_radius` (`getRadius/setRadius`)\n\n   ![](/_arts/hbl_radius.png)\n\n- `hbl_second_radius` (`getSecondRadius/setSecondRadius`)\n\n   ![](/_arts/hbl_second_radius.png)\n\n- `hbl_second_alpha` (`getSecondAlpha/setSecondAlpha`)\n\n   ![](/_arts/hbl_second_alpha.png)\n\n- `hbl_offset_x` (`getOffsetX/setOffsetX`)\n\n   ![](/_arts/hbl_offset_x.png)\n\n- `hbl_offset_y` (`getOffsetY/setOffsetY`)\n\n   ![](/_arts/hbl_offset_y.png)\n\n- `hbl_animate_holding_view` (`setAnimateHoldingView/isAnimateHoldingView`)\n\n## License\n\n```\nCopyright (C) 2017 Artem Glugovsky\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```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhluhovskyi%2FHoldingButton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhluhovskyi%2FHoldingButton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhluhovskyi%2FHoldingButton/lists"}