I have edittext on my Xml layout. When the app launch, keyboard is coming and focusing to edittext. I dont want this. How can I unfocus it on Android Studio ?
Asked
Active
Viewed 50 times
3 Answers
1
Use this line in your activity it will hide your soft input
keyboardthis.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Alternatively, you can use
edittext.clearFocus();

Ajeett
- 814
- 2
- 7
- 18
1
set below property of your parent/Top level layout.
android:focusable="true"
android:focusableInTouchMode="true"
and Its working Nicely :)

niceumang
- 1,347
- 1
- 8
- 21
0
Set this following line with your activity tag in manifest
android:windowSoftInputMode="stateHidden"
or
you can set following line in oncreate method of your activity
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

Apps Maven
- 1,314
- 1
- 4
- 17