简体   繁体   中英

I want my FAB to stay at the bottom of the screen

在此处输入图片说明 I am using the Floating Action Button for my app and have a question on what I am stuck on. It works fine etc but when I click on an EditText in the center of the screen, the keyboard comes but...but so does the FAB. I want it to stay at the bottom of the screen. Is there a way?

<FrameLayout
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<LinearLayout
    android:orientation="vertical"
    android:id="@+id/title_note_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/noteTitle"
        android:fontFamily="sans-serif-light"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Note Title"
        android:textSize="28sp"
        android:layout_marginTop="8dp"
        android:layout_marginLeft="10dp"/>
    <EditText
        android:fontFamily="sans-serif-light"
        android:textSize="20sp"
        android:id="@+id/edit_note_title"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="50dp"
        android:layout_marginRight="10dp"/>
</LinearLayout>
<LinearLayout
    android:orientation="vertical"
    android:id="@+id/edit_note_notes"
    android:layout_below="@+id/title_note_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <EditText
        android:fontFamily="sans-serif-light"
        android:background="@android:color/transparent"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:hint="Empty"
        android:id="@+id/edit_note"
        android:paddingLeft="10dp"
        android:paddingTop="10dp"
        android:gravity="start"/>

</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center"
    android:layout_margin="16dp"
    android:clickable="true"
    android:src="@drawable/menuicon" />

Good practice is to hide the FAB when the soft keyboard comes up.

Please add:

android:windowSoftInputMode="stateAlwaysHidden|adjustPan"

to the corresponding activity in your AndroidManifest. Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM