上述移动悬浮式键盘操作按钮 [英] Move Floating Action Button above keyboard
问题描述
我有这个浮动操作按钮(GitHub的链接),当我打开(软件)键盘浮动操作按钮隐藏键盘后面。
有没有办法,我可以把它在键盘上方?
编辑:
tab_random.xml
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent> <查看
机器人:layout_width =match_parent
机器人:layout_height =156dp
机器人:背景=@彩色/ primary_color
/> <的EditText
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:ID =@ + ID /来自
安卓的inputType =数字
机器人:imeOptions =actionNext
机器人:layout_centerHorizontal =真
机器人:提示=从
机器人:paddingStart =5DP
机器人:文字颜色=#FFF
机器人:fontFamily中=无衬线光
机器人:TEXTSIZE =44sp
机器人:backgroundTint =@彩色/ fab_ripple
机器人:layout_marginStart =10dp
/> <的EditText
机器人:TEXTSIZE =44sp
机器人:layout_marginStart =10dp
机器人:paddingStart =5DP
机器人:fontFamily中=无衬线光
机器人:layout_centerHorizontal =真
机器人:layout_below =@ + ID /来自
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:提示=要
安卓的inputType =数字
机器人:imeOptions =actionSend
/>
< / RelativeLayout的>
activity_main.xml中
< RelativeLayout的
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
的xmlns:FAB =http://schemas.android.com/apk/res-auto
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直
工具:上下文=activity.MainActivity> <包括
机器人:ID =@ + ID /工具栏
布局=@布局/ tool_bar/> < slidingModel.SlidingTabLayout
机器人:layout_below =@ + ID /工具栏
机器人:ID =@ + ID /标签
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:海拔=4DP
机器人:背景=@彩色/ primary_color
/> < android.support.v4.view.ViewPager
机器人:layout_below =@ ID /标签
机器人:ID =@ + ID /寻呼机
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =match_parent /> < com.melnykov.fab.FloatingActionButton
机器人:ID =@ + ID / FAB
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =底部|结束
机器人:layout_margin =16DP
FAB:fab_colorNormal =@彩色/ fab_normal
FAB:fab_color pressed =@色/ fab_ pressed
FAB:fab_colorRipple =@彩色/ fab_ripple
机器人:layout_marginLeft =16DP
机器人:layout_marginRight =16DP
机器人:layout_alignParentBottom =真
机器人:layout_alignParentEnd =真/>< / RelativeLayout的>
您的布局是这样的现在:
<相对布局>
<查看/>
<的EditText />
<其它的东西... />
< / RelativeLayout的>
您需要添加RelativeLayout的标签内的滚动视图。此外,scrollviews不喜欢有一个以上的直接子视图,所以你需要滚动视图内一个RelativeLayout的。所以,你的布局将风这样看:
<&RelativeLayout的GT; (这是已经在这里)
<&滚动型GT; (这是新)
<&RelativeLayout的GT; (这也是新)
<查看,EditText上,等等。在这里/> (这是过去,原来相对布局内)。
< / RelativeLayout的> (收了新的RelativeLayout)
< /滚动型> (关新的滚动型)
< / RelativeLayout的> (关闭原始相对布局。)
I have this Floating Action Button (GitHub link) and when I open a (software) keyboard the Floating Action Button hides behind the keyboard.
Is there a way that I can push it above the keyboard?
Edit:
tab_random.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="match_parent"
android:layout_height="156dp"
android:background="@color/primary_color"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/from"
android:inputType="number"
android:imeOptions="actionNext"
android:layout_centerHorizontal="true"
android:hint="From"
android:paddingStart="5dp"
android:textColor="#FFF"
android:fontFamily="sans-serif-light"
android:textSize="44sp"
android:backgroundTint="@color/fab_ripple"
android:layout_marginStart="10dp"
/>
<EditText
android:textSize="44sp"
android:layout_marginStart="10dp"
android:paddingStart="5dp"
android:fontFamily="sans-serif-light"
android:layout_centerHorizontal="true"
android:layout_below="@+id/from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="To"
android:inputType="number"
android:imeOptions="actionSend"
/>
</RelativeLayout>
activity_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="activity.MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/tool_bar" />
<slidingModel.SlidingTabLayout
android:layout_below="@+id/toolbar"
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:background="@color/primary_color"
/>
<android.support.v4.view.ViewPager
android:layout_below="@id/tabs"
android:id="@+id/pager"
android:layout_height="wrap_content"
android:layout_width="match_parent"
/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
fab:fab_colorNormal="@color/fab_normal"
fab:fab_colorPressed="@color/fab_pressed"
fab:fab_colorRipple="@color/fab_ripple"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Your layout is like this right now:
<Relative Layout>
<View/>
<EditText/>
<other stuff.../>
</RelativeLayout>
You need to add a scrollview inside the RelativeLayout tags. Also, scrollviews don't like having more than one direct child view, so you'll need a Relativelayout inside of the scrollview. So, your layout will wind up looking like this:
<RelativeLayout> (this was already here)
<ScrollView> (this is new)
<RelativeLayout> (this is also new)
<View, EditText, Etc. in here/> (this is what used to be inside that original relative layout.)
</RelativeLayout> (closing up the new Relativelayout)
</ScrollView> (closing the new Scrollview)
</RelativeLayout> (closing the original Relative Layout.)
这篇关于上述移动悬浮式键盘操作按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!