{"id":21130045,"url":"https://github.com/IanGClifton/AndroidFloatLabel","last_synced_at":"2025-07-09T01:32:09.471Z","repository":{"id":12868820,"uuid":"15545140","full_name":"IanGClifton/AndroidFloatLabel","owner":"IanGClifton","description":"Library project with a custom view that implements the Float Label pattern","archived":false,"fork":false,"pushed_at":"2015-05-23T01:46:52.000Z","size":1125,"stargazers_count":471,"open_issues_count":0,"forks_count":93,"subscribers_count":29,"default_branch":"master","last_synced_at":"2023-11-07T15:24:40.436Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/IanGClifton.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","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":"2013-12-31T07:08:43.000Z","updated_at":"2023-11-03T06:14:08.000Z","dependencies_parsed_at":"2022-07-13T21:44:24.636Z","dependency_job_id":null,"html_url":"https://github.com/IanGClifton/AndroidFloatLabel","commit_stats":null,"previous_names":[],"tags_count":5,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IanGClifton%2FAndroidFloatLabel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IanGClifton%2FAndroidFloatLabel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IanGClifton%2FAndroidFloatLabel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IanGClifton%2FAndroidFloatLabel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IanGClifton","download_url":"https://codeload.github.com/IanGClifton/AndroidFloatLabel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225476377,"owners_count":17480215,"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-20T05:32:13.390Z","updated_at":"2024-11-20T05:32:17.053Z","avatar_url":"https://github.com/IanGClifton.png","language":"Java","funding_links":[],"categories":["Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"AndroidFloatLabel\n=================\n\nThis repository contains an Android library project for Android 4.0+ with a custom view that implements the Float Label pattern (http://dribbble.com/shots/1254439--GIF-Float-Label-Form-Interaction) and an example project using the Float Label library.  The custom View, FloatLabel, basically consists of two pieces: the EditText and the label (a TextView).\n\nQuick Overview\n--------------\n\n- [YouTube demo](http://www.youtube.com/watch?v=9VoVxw8aAx0)\n- [Google Play example app](https://play.google.com/store/apps/details?id=com.iangclifton.android.floatlabelexample)\n\nGetting Started\n---------------\n\nDownload the source to use it as a library project or use it directly from Maven Central in your dependencies.  For example:\n\n\tdependencies {\n\t\tcompile 'com.iangclifton.android:floatlabel:1.0.4'\n\t}\n\nFor most use, you can simply use the custom view in your XML layout, specifying a label to use as both the EditText hint and the label TextView with the \u003ccode\u003eandroid:hint\u003c/code\u003e property.  Example:\n\n    \u003ccom.iangclifton.android.floatlabel.FloatLabel\n        android:id=\"@+id/float_label_1\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:hint=\"@string/example_label\" /\u003e\n\nYou can also dynamically set the label with \u003ccode\u003efloatLabel.setLabel(\"Custom Label\")\u003c/code\u003e or \u003ccode\u003efloatLabel.setLabel(R.string.custom_label)\u003c/code\u003e. You can dynamically set the text of the EditText with \u003ccode\u003efloatLabel.setText()\u003c/code\u003e. All the typical setText variations are supported. If you want to set the text without an animation (such as if you're programmatically preparing views in onCreate), use \u003ccode\u003efloatLabel.setTextWithoutAnimation()\u003c/code\u003e (again, all the usual variations are supported).\n\nIf you need a reference to the EditText, you can call \u003ccode\u003efloatLabel.getEditText()\u003c/code\u003e.\n\nCustom Layout\n-------------\n\nIf you want to specify a custom layout to use, you can do something like this:\n\n    \u003ccom.iangclifton.android.floatlabel.FloatLabel\n        android:id=\"@+id/float_label_custom_layout_1\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:hint=\"@string/example_label\"\n        android:layout=\"@layout/custom_float_label\" /\u003e\n\nYour custom layout should include a label TextView (\u003ccode\u003eid/float_label\u003c/code\u003e) and an EditText (\u003ccode\u003eid/edit_text\u003c/code\u003e).  The custom layouts are extremely limited because the FloatLabel simply lays out the label and the EditText and ignores all other views.  This is very efficient but also prevents you from creating a much more complex layout.  Here's an example:\n\n    \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n    \u003cmerge xmlns:android=\"http://schemas.android.com/apk/res/android\" \u003e\n        \u003cTextView\n            android:id=\"@id/float_label\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:lines=\"1\"\n            android:textIsSelectable=\"true\"\n            android:textAppearance=\"?android:attr/textAppearanceSmall\" /\u003e\n        \u003cEditText\n            android:id=\"@id/edit_text\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:inputType=\"text|textAutoCorrect|textCapSentences|textAutoComplete\" /\u003e\n    \u003c/merge\u003e\n\nCustom Animation\n----------------\n\nYou can override the animations used to show and hide the label by implementing a \u003ccode\u003eFloatLabel.LabelAnimator\u003c/code\u003e and calling \u003ccode\u003efloatLabel.setLabelAnimator(new MyLabelAnimator());\u003c/code\u003e.  Note that you should use the alpha property of the label to show and hide it rather than the View.setVisibility(int) method.  Example:\n\n    private static class CustomLabelAnimator implements FloatLabel.LabelAnimator {\n        /*package*/ static final float SCALE_X_SHOWN = 1f;\n        /*package*/ static final float SCALE_X_HIDDEN = 2f;\n        /*package*/ static final float SCALE_Y_SHOWN = 1f;\n        /*package*/ static final float SCALE_Y_HIDDEN = 0f;\n\n        @Override\n        public void onDisplayLabel(View label) {\n            final float shift = label.getWidth() / 2;\n            label.setScaleX(SCALE_X_HIDDEN);\n            label.setScaleY(SCALE_Y_HIDDEN);\n            label.setX(shift);\n            label.animate().alpha(1).scaleX(SCALE_X_SHOWN).scaleY(SCALE_Y_SHOWN).x(0f);\n        }\n\n        @Override\n        public void onHideLabel(View label) {\n            final float shift = label.getWidth() / 2;\n            label.setScaleX(SCALE_X_SHOWN);\n            label.setScaleY(SCALE_Y_SHOWN);\n            label.setX(0f);\n            label.animate().alpha(0).scaleX(SCALE_X_HIDDEN).scaleY(SCALE_Y_HIDDEN).x(shift);\n        }\n    }\n\n\nRelated Projects\n----------------\n\n* [Fork of Float Label for Android 2.3+](https://github.com/edouardouvrard/AndroidFloatLabel-API9)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIanGClifton%2FAndroidFloatLabel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIanGClifton%2FAndroidFloatLabel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIanGClifton%2FAndroidFloatLabel/lists"}