{"id":20135964,"url":"https://github.com/scacap/rubberbandview","last_synced_at":"2026-05-09T21:34:42.009Z","repository":{"id":91171271,"uuid":"121438825","full_name":"ScaCap/RubberBandView","owner":"ScaCap","description":"A custom view that simulates the behaviour of a rubber band for Android","archived":false,"fork":false,"pushed_at":"2024-02-06T07:55:26.000Z","size":1230,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-01-13T09:38:09.850Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":false,"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/ScaCap.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-13T21:29:24.000Z","updated_at":"2024-04-03T14:38:07.000Z","dependencies_parsed_at":"2023-12-19T21:32:08.490Z","dependency_job_id":"fe8feefd-a9de-43ce-8a85-2adb96d67744","html_url":"https://github.com/ScaCap/RubberBandView","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScaCap%2FRubberBandView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScaCap%2FRubberBandView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScaCap%2FRubberBandView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScaCap%2FRubberBandView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScaCap","download_url":"https://codeload.github.com/ScaCap/RubberBandView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241582522,"owners_count":19985846,"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-11-13T21:17:10.736Z","updated_at":"2026-05-09T21:34:41.962Z","avatar_url":"https://github.com/ScaCap.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RubberBandView\n\nA custom view that simulates the behaviour of a rubber band for Android. More details [here](https://engineering.scalable.capital/2018/02/25/rubberbandview-a-custom-view.html).\n\n![](screenshots/rubber_loading.gif)\n\n## Usage\n\n### Minimum setup\n\nIn your layout file:\n\n```\n\u003ccapital.scalable.droid.rubberbandview.RubberBandView\n    android:id=\"@+id/rubberBandView\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\" /\u003e\n```\n\n### Max selectable value\n\nThe API of the custom view is similar to that of Android's [ProgressBar](https://developer.android.com/reference/android/widget/ProgressBar.html). You must set the max selectable value, using:\n\n```\nRubberBandView rubberbandView = findViewById(R.id.rubberBandView);\nrubberBandView.setMaxSelection(10);\n```\n\nThis way, the user can select any value from the range [0,10].\n\n### RubberBandListener\n\nTo receive updates to the selected value:\n\n```\nrubberBandView.setListener(new RubberBandListener() {\n    @Override\n    public void onSelectionChanged(int value) {\n        Toast.makeText(MainActivity.this, \"Selection changed to \" + value, Toast.LENGTH_SHORT).show();\n    }\n\n    @Override\n    public void onSelectionFinished(int value) {\n        Toast.makeText(MainActivity.this, \"Selection ended with value \" + value, Toast.LENGTH_SHORT).show();\n    }\n});\n```\n\nThe `onSelectionFinished` event is triggered as soon as the user has lifted their finger off the view. Note that the value returned in that case is the final selected one.\n\n### Vibration animation\n\nThe view comes with a nudge animation, that encourages the user to interact with it.\n\n![](screenshots/rubber_vibration.gif)\n\nThe default animation uses a [ValueAnimator](https://developer.android.com/reference/android/animation/ValueAnimator.html), which looks like this:\n\n```\nvibrationAnimator = ValueAnimator.ofFloat(-1f, 1f, -0.5f, 0.5f, 0);\nvibrationAnimator.setInterpolator(new DecelerateInterpolator());\nvibrationAnimator.setRepeatCount(3);\nvibrationAnimator.setDuration(200 / 3);\nvibrationAnimator.setStartDelay(5000);\n```\n\nYou can supply your own animator, using:\n\n`rubberBandView.setVibrationAnimator(customAnimator)`\n\nTo turn the animation off completely, simply set the vibration animator to `null`.\n\n### UI Customization\n\nThese are the parameters that can be modified through xml:\n\n```\n\u003ccapital.scalable.droid.rubberbandview.RubberBandView\n    app:loosenessRatio=\"0.2\"\n    app:rubberColor=\"@color/colorAccent\"\n    app:minRubberWidth=\"4dp\"\n    app:maxRubberWidth=\"5dp\"\n    app:vibrationPeakAmplitude=\"3dp\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\" /\u003e\n```\n\n- `loosenessRatio`: how loose the rubber needs to be. Must be in [0, 1] range. Defaults to 0.4\n- `rubberColor`: the color of the rubber. Defaults to the theme's `colorAccent`\n- `minRubberWidth`: the minimum width of the rubber band, in dp. This will be the width when the rubber band is pulled to its max.\n- `maxRubberWidth`: the maximum width of the rubber band, in dp. This will be the width when the rubber band is at rest.\n- `vibrationPeakAmplitude`: the maximum displacement of the rubber band when vibrating, in dp.\n\n\n## Installation\n\n``` groovy\nrepositories {\n    maven { url \"https://jitpack.io\" }\n}\n\n\ndependencies {\n    implementation \"com.github.ScaCap:RubberBandView:1.0.0\"\n}\n```\n\n## License\n\nRubberBandView is Open Source software released under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscacap%2Frubberbandview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscacap%2Frubberbandview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscacap%2Frubberbandview/lists"}