Custom EditText is not showing keyboard on focus
Make custom EditText with Kotlin to fix focus problem:
class MyEditText @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = android.R.attr.editTextStyle) : AppCompatEditText(context, attrs, defStyleAttr) {
init {
doSomething(context)
}
private fun doSomething(context: Context) {
// TODO Set your custom font or whatever you need
}
}
It's an old question but if someone cares, the problem is on the implementation of the constructor:
public CustomFontEditText(Context context, AttributeSet attrs) {
this(context, attrs, 0);
this.context = context;
}
The last argument ("defStyle") which you set as 0, should be the default style for an EditText. If you take a look at the same constructor on the EditText class:
public EditText(Context context, AttributeSet attrs) {
this(context, attrs, com.android.internal.R.attr.editTextStyle);
}
As you can see, the default style for an EditText should be used, so your constructor should look like this:
public CustomFontEditText(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.editTextStyle);
this.context = context;
}