Skip to content

Instantly share code, notes, and snippets.

@suzp1984
Created December 12, 2019 23:04
Show Gist options
  • Save suzp1984/67134895358649695080b89be86563af to your computer and use it in GitHub Desktop.
Save suzp1984/67134895358649695080b89be86563af to your computer and use it in GitHub Desktop.
custom input delegate view
class InputDelegateView @JvmOverloads constructor(context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0,
defStyleRes: Int = 0):
View(context, attrs, defStyle, defStyleRes) {
var delegateConnection: InputConnection? = null
init {
isFocusable = true
isFocusableInTouchMode = true
}
override fun onCreateInputConnection(outAttrs: EditorInfo?): InputConnection {
// we should write a custome declare-styleable to custom the inputType, and also the ime options
outAttrs?.inputType = InputType.TYPE_CLASS_TEXT
return delegateConnection ?: super.onCreateInputConnection(outAttrs)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment