我想在Android的默认键盘上方添加一个按钮,我想重复使用很多次。
这样的事情:
所以,在这种情况下,我是否需要创建一个新的自定义键盘,或者每次我想在键盘上方使用此按钮时,是否有办法以编程方式添加此按钮?
任何人都可以推荐正确的方法。任何帮助都非常感谢。感谢
答案 0 :(得分:1)
首先......它就像一个技巧......在你的布局中添加以下代码
<RelativeLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center">
<Button
android:id="@+id/sendMsgButton"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_margin="0dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:background="#FF9800"
android:text="This button"
android:textSize="20dp"
android:textColor="#ffffff" />
</RelativeLayout>
然后在正确的位置使用hese 2代码动态显示或隐藏(在键盘监听器中):
button.setVisibility(View.VISIBLE)
button.setVisibility(View.INVISIBLE)
答案 1 :(得分:0)
我认为要走的路是实现一个监听器来检查键盘是否可见并切换按钮的可见性。对于按钮,我建议使用RelativeLayout或FrameLayout作为父视图,按钮对齐到底部。