我有这个Floating Action Button (GitHub link)当我打开(软件)键盘时, float 操作按钮隐藏在键盘后面。
有什么方法可以将它推到键盘上方吗?
编辑:
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>
最佳答案
你现在的布局是这样的:
<Relative Layout>
<View/>
<EditText/>
<other stuff.../>
</RelativeLayout>
您需要在 RelativeLayout 标签内添加一个 ScrollView 。此外, ScrollView 不喜欢拥有多个直接 subview ,因此您需要在 ScrollView 内设置一个 Relativelayout。因此,您的布局最终将如下所示:
<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.)
关于android - 将 float 操作按钮移到键盘上方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32216564/