横向模式下右侧的Keyboardview

时间:2019-10-12 17:56:39

标签: java android android-studio android-intent

我想制作一个自定义键盘,该键盘位于屏幕的右边缘。在很大程度上,我做到了。但是当涉及windowSoftInputMode="adjustResize"时,所有内容都会被推出屏幕。

我的自定义键盘上只有几个键。这基本上是为了参加会议。因此,我希望它们位于屏幕的右侧,并具有足够的空间来查看与会者的姓名。但是看来键盘只会从底部弹出。

我尝试使用:

<android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="120dp"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:background="@android:color/transparent"
    android:layout_gravity="right"
    android:foregroundGravity="right"
    app:layout_anchorGravity="right"/>

我注意到更改layout_width的影响为零。因此,我尝试在键盘布局文件中使用android:horizontalGap' attribute on`进行破解:

<Keyboard ...>
    <Row>
        <Key android:keyLabel="Absent"
            android:codes="A"
            android:keyEdgeFlags="left"/>
        <Key .../>
    </Row>

在大多数情况下,它运行良好。 desired and achieved layout

但是在大​​多数应用程序中,当我尝试在默认android消息应用程序上编辑文本时,会发生以下情况: undesired layout

一切都被推出屏幕。我的猜测是,windowSoftInputMode="adjustResize"属性将EditText设置在键盘上方,从而将所有内容都投射到屏幕之外。

那么,我该如何解决?首选解决方案是将键盘完全固定在屏幕的右侧和应用程序外部,而不是底部。我尝试过,但是找不到合适的解决方案。另一个“好的”解决方案是强制应用程序不要“ adjustResize”。任何帮助表示赞赏。谢谢。

0 个答案:

没有答案