Android 如何使浮动操作按钮和编辑文本同时位于键盘上方?
我目前正在为我的布局而挣扎,我被卡住了。我有两个编辑文本,第二个可以是多行的,我想在添加新行和显示键盘时调整布局。我也希望我的晶圆厂一直在键盘上方。本质上,我希望在写便条时有与Google Keep相同的行为 以下是我的布局: 活动_fragment.xmlAndroid 如何使浮动操作按钮和编辑文本同时位于键盘上方?,android,android-layout,floating-action-button,Android,Android Layout,Floating Action Button,我目前正在为我的布局而挣扎,我被卡住了。我有两个编辑文本,第二个可以是多行的,我想在添加新行和显示键盘时调整布局。我也希望我的晶圆厂一直在键盘上方。本质上,我希望在写便条时有与Google Keep相同的行为 以下是我的布局: 活动_fragment.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<!-- app:layout_behavior must be inside CoordinatorLayout (not in fragment) for correct scroll behavior -->
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_horizontal_margin"
app:layout_anchor="@id/fragment_container"
app:layout_anchorGravity="bottom|right|end"/>
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/fragment_note_detail_title_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/recyclerview_margin"
android:layout_marginLeft="@dimen/recyclerview_margin"
android:layout_marginRight="@dimen/recyclerview_margin"
android:hint="@string/title_hint"
android:textStyle="bold"
android:singleLine="true"
android:imeOptions="actionNext"
tools:text="Title goes here"/>
<EditText
android:id="@+id/fragment_note_detail_description_edittext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/recyclerview_margin"
android:hint="@string/description_hint"
android:gravity="top|start"
tools:text="Description goes here"/>
</LinearLayout>
对于特定的活动,则FAB保持在键盘上方,但当添加新行时,第二个编辑文本被键盘重叠
当我设定
android:windowSoftInputMode="adjustResize"
android:windowSoftInputMode="adjustPan"
然后编辑文本和光标始终位于键盘上方,但键盘始终与FAB重叠
如何使两者(FAB和光标始终可见)?您可以在WindowsofInputMode中设置两个或多个方法,如文档中所述:
请检查此项,它将帮助您提高内容质量
<activity android:windowSoftInputMode="stateVisible|adjustResize" ...