Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 强制键盘在屏幕上显示_Android_Keyboard - Fatal编程技术网

Android 强制键盘在屏幕上显示

Android 强制键盘在屏幕上显示,android,keyboard,Android,Keyboard,我需要软键盘显示在屏幕上,没有编辑文本,只有键盘。 我有一个想法,游戏将由一个软键盘控制,但我在stackoverflow上发现的东西——并没有发挥应有的作用 这是my game.xml-它是此应用程序主要活动的布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/root" xmlns:tools="http://schemas.an

我需要软键盘显示在屏幕上,没有编辑文本,只有键盘。 我有一个想法,游戏将由一个软键盘控制,但我在stackoverflow上发现的东西——并没有发挥应有的作用

这是my game.xml-它是此应用程序主要活动的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/root"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".GameActivity" >

    <com.vladdrummer.textmaster.Game
        android:id="@+id/game"
        android:layout_width="wrap_content"
        android:windowSoftInputMode="adjustResize"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>
这只适用于纵向/垂直方向,不适用于横向/水平方向

在这种情况下,我的游戏类是扩展视图类,我正在使用画布

但我需要以水平模式显示

还有另一种保持键盘在屏幕上的方法:

((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
但那没用


所以,请,我需要一个软键盘粘贴在屏幕上,在横向模式下

尝试在一个单独的读卡器中执行以下代码

  InputMethodManager im = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
  if(im != null)  im.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
  InputMethodManager im = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
  if(im != null)  im.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);