Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Hide keyboard when activity starts

I have an activity with lots of edittext. whenever I load that activity, the keyboard appears and eats half of the screen which makes that activity's look bad. So is there any way to hide keyboard when I load that activity.

like image 749
Caution Continues Avatar asked Dec 10 '12 12:12

Caution Continues


2 Answers

in your onCreate() use this..

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
like image 148
Mehul Ranpara Avatar answered Sep 21 '22 22:09

Mehul Ranpara


Add this two line in your activity's XML file in the RootLayout i.e. either relative or linear(whatever you have taken) :

android:focusableInTouchMode="true" 

Add this line in activity manifests file

 android:windowSoftInputMode="stateHidden"
like image 42
AndroidLearner Avatar answered Sep 19 '22 22:09

AndroidLearner