I have an EditText
<EditText
android:id="@+id/edite_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="24sp"
android:fontFamily="@font/main_font"
android:autofillHints=""
android:maxLength="25"
android:layout_marginTop="30dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="30dp"
android:gravity="center"
android:inputType="text"/>
I’m using it in a custom Dialog
private fun createAddDialog(){
val dialog = Dialog(this)
dialog.setContentView(R.layout.category_dialog_create)
dialog.window!!.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
dialog.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
//dialog.window!!.attributes.windowAnimations = R.style.DialogAnimationDown
dialog.setCancelable(true)
val editText: EditText = dialog.findViewById(R.id.edite_name)
dialog.show()
}
But for some reason, when I click on EditText, the keyboard does not open. The problem is both in the emulator and in the real device. Similar code works in another project
I tried to call the keyboard programmatically and it opens but the text does not fit into the EditText
val editText: EditText = dialog.findViewById(R.id.edite_name)
dialog.show()
editText.requestFocus()
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0)