FloatingActionButton 悬浮在 自定义键盘KeyboardView 之上

寒冰大神 2018-05-26 10:01:38
如图 配货按钮 FloatingActionButton 悬浮于KeyboardView之上,怎么让他在键盘下面呢?不让FloatingActionButton遮挡键盘

xml如下: DragFloatActionButton 是继承 FloatingActionButton实现的

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/red"
android:clipToPadding="true"
android:fitsSystemWindows="true">

<......>
<com.gzquants.commonlibrary.widget.DragFloatActionButton
android:id="@+id/submit"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:scaleType="center"
android:src="@drawable/ic_peihuo"
app:borderWidth="0.0dp"
app:fabSize="normal" />

<android.inputmethodservice.KeyboardView
android:id="@+id/keyboard_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="@color/black500"
android:focusable="true"
android:focusableInTouchMode="true"
android:keyBackground="@color/tab_back"
android:keyPreviewLayout="@layout/preview_keyboard"
android:keyTextColor="@color/black"
android:keyTextSize="25sp"
android:labelTextSize="25sp"
android:paddingTop="5dp"
android:shadowColor="@color/white"
android:shadowRadius="0.0" />

</RelativeLayout>

DragFloatActionButton 和 KeyboardView 调换位置结果还是一样。
...全文
1567 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_33539969 2018-05-29
  • 打赏
  • 举报
回复
只判断y坐标就行了,x坐标无所谓,当你你打开键盘的时候,(FloatingActionButton 的 y + FloatingActionButton 本身的高度 )小于 键盘的y,就显示, 否则就隐藏
寒冰大神 2018-05-28
  • 打赏
  • 举报
回复
引用 4 楼 xj396282771 的回复:
能不能设置个键盘的监听事件啊,当弹出键盘时隐藏掉FloatingActionButton,关闭键盘时显示FloatingActionButton
不行,这个FloatingActionButton 是可以拖动的,位置可以改变的,当他不在键盘上就不能隐藏了。
Jing丶無雙 2018-05-28
  • 打赏
  • 举报
回复
能不能设置个键盘的监听事件啊,当弹出键盘时隐藏掉FloatingActionButton,关闭键盘时显示FloatingActionButton
Jing丶無雙 2018-05-28
  • 打赏
  • 举报
回复
引用 5 楼 qq_34364155 的回复:
不行,这个FloatingActionButton 是可以拖动的,位置可以改变的,当他不在键盘上就不能隐藏了。
FloatingActionButton 拖动过程中能获取到当前坐标位置么?如果可以,当弹出键盘时,先判断FloatingActionButton 坐标y值在不在弹出键盘的范围中,再去隐藏
寒冰大神 2018-05-26
  • 打赏
  • 举报
回复
怎么让FloatingActionButton 不悬浮呢
寒冰大神 2018-05-26
  • 打赏
  • 举报
回复
外层RelativeLayout 换成FrameLayout 也是一样,
寒冰大神 2018-05-26
  • 打赏
  • 举报
回复
View parentView = (View) keyboardView.getParent();// 解决遮盖问题 keyboardView.bringToFront(); parentView.requestLayout(); parentView.invalidate(); 这个方法无效----

80,361

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧