Created
November 9, 2020 08:32
-
-
Save serhatleventyavas/43abb54acea9a995d27cb1ce3b2dca4d to your computer and use it in GitHub Desktop.
TextInputLayout Kotlin Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val relativeLayout = view.findViewById<RelativeLayout>(R.id.edit_profile_relative_layout) | |
val emailTextInputLayout = TextInputLayout(requireContext(), null, R.style.Widget_MaterialComponents_TextInputLayout_OutlinedBox) | |
val emailTextInputLayoutParams : LinearLayout.LayoutParams = LinearLayout.LayoutParams( | |
LinearLayout.LayoutParams.MATCH_PARENT, | |
LinearLayout.LayoutParams.WRAP_CONTENT | |
) | |
emailTextInputLayout.hint = "Please Enter Email Address" | |
emailTextInputLayout.boxBackgroundMode = TextInputLayout.BOX_BACKGROUND_OUTLINE | |
emailTextInputLayout.setBackgroundColor(Color.WHITE) | |
emailTextInputLayoutParams.setMargins(0,0,0,10) | |
emailTextInputLayout.layoutParams = emailTextInputLayoutParams | |
emailTextInputLayout.setBoxCornerRadii(5f, 5f, 5f, 5f) | |
val edtEmail = TextInputEditText(emailTextInputLayout.context) | |
val edtEmailParams: LinearLayout.LayoutParams = LinearLayout.LayoutParams( | |
LinearLayout.LayoutParams.MATCH_PARENT, | |
LinearLayout.LayoutParams.WRAP_CONTENT | |
) | |
edtEmail.compoundDrawablePadding = 10 | |
edtEmail.inputType = InputType.TYPE_CLASS_PHONE | |
edtEmail.imeOptions = EditorInfo.IME_ACTION_DONE | |
edtEmail.layoutParams = edtEmailParams | |
emailTextInputLayout.addView(edtEmail) | |
relativeLayout.addView(emailTextInputLayout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment