Program's main UI of my App is divided into two sections, Made up of two LinearLayouts.The LinearLayout above aims to show the aircraft.The LinearLayout below aims to show the soft keyboard.I want to use keys on the soft keyboard to control the movement of aircraft. For example ,if I press the key 's' on the soft keyboard,the aircraft will move to the left.But I do not konw how to show the soft keyboard on the LinearLayout below.can you do me a favor?
Asked
Active
Viewed 782 times
4 Answers
0
Use windowSoftInputMode="stateAlwaysVisible"
in your manifest to show keyboard

Vivek Mishra
- 5,669
- 9
- 46
- 84
0
It's better to make your custom buttons, but you can achieve what you want by
- Embedding an EditText in your layout and make it
invisible
orgone
. - Programatically hide/show your keyboard using this utility class.

Ahmed Hegazy
- 12,395
- 5
- 41
- 64
0
In addition to what others here suggested (to show the keyboard) you can use this in order for softKeboard to "do nothing" to your layouts:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
or in your Manifest:
android:windowSoftInputMode="adjustNothing"
I think you should consider setting buttons in your layout, and not using the android keyboard... but this is just a suggestion.

e-shfiyut
- 3,538
- 2
- 30
- 31
0
You can use this in your manifest
android:windowSoftInputMode="stateVisible"
It shows the keyboard at startup of activity and you can get the key event by overriding dispatchKeyEvent
and getting KeyEvent.KEYCODE_S
like here
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(event.getKeyCode() == KeyEvent.KEYCODE_S){
//Do whatever you want here
}
return super.dispatchKeyEvent(event);
}

Shree Krishna
- 8,474
- 6
- 40
- 68