适用于Android键盘的附件视图(类似于iOS的inputAccessoryView)

F L*_*F L 6 java android android-softkeyboard

有人可以指导我如何添加类似于inputAccessoryView for Android的东西吗?

我想添加一行额外的自定义按钮,如键盘上方的栏中所示:

在此输入图像描述

谢谢!

PS我使用的是标准默认键盘.

Com*_*are 6

除非您创建自己的输入法编辑器,否则这是不可能的.您无法从应用程序修改其他人的输入法编辑器.

在屏幕截图中,您认为"额外的一行自定义按钮"不是输入法编辑器的一部分.这是活动的一部分.如果我不得不猜测,该活动的布局文件看起来大致如此(仅限伪代码 - 这不会直接编译):

<LinearLayout android:orientation="vertical">
  <ScrollView android:layout_height="0dp" android:layout_weight="1">
    <LinearLayout android:orientation="vertical">
      <!-- the form goes in here -->
    </LinearLayout>
  </ScrollView>
  <LinearLayout android:orientation="horizontal" android:layout_height="wrap_content">
    <!-- the button bar goes here -->
  </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这与清单中android:windowSoftInputMode="adjustResize"<activity>元素一起,应该为您提供所需的UI - 按钮栏将位于输入法编辑器的正上方.