1

I'm trying to build a layout like the following:

layout screenshot

As you can see, you can add new tasks but the buttons at the bottom should always be visible.

This is working with the following XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:float="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:showIn="@layout/activity_edit_reminder">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/label_reminder_location"
        android:textColor="@color/colorPrimary"
        android:id="@+id/labelLocationSpinner" />

    <Spinner
        android:id="@+id/locationSpinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:contentDescription="@string/label_reminder_location"
        android:minHeight="32dp" />

    <Switch
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/label_reminder_enabled"
        android:textColor="@color/colorPrimary"
        android:id="@+id/editReminderEnabled"
        android:layout_marginTop="5dp"
        android:enabled="true"
        />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/editReminderContent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </ScrollView>
</LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="2dp"
    android:orientation="horizontal">
    <Button
        android:id="@+id/button_delete"
        android:text="@string/button_delete"
        android:onClick="deleteReminder"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight=".50"
        android:layout_marginEnd="5dp"
        android:background="@drawable/ripple_red"
        android:textColor="#ffffff"
        />

    <Button
        android:id="@+id/button_save"
        android:text="@string/button_save"
        android:onClick="saveReminder"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight=".50"
        android:layout_marginStart="5dp"
        android:background="@drawable/ripple_green"
        />
</LinearLayout>

</LinearLayout>

As you can see, I'm using an EditText inside the Scrollview. It will then become a scrollable checklist by using this amazing library: https://github.com/federicoiosue/checklistview

What is missing is that I'd like the buttons to stay behind the keyboard when the user is writing tasks. Right now, this will happen:

layout with keyboard

If I add android:windowSoftInputMode="adjustNothing" to my manifest for that activity, then when the keyboard is shown it will overlap the tasks and buttons.

koichirose
  • 1,815
  • 4
  • 22
  • 30

1 Answers1

0

You should use in your Android Manifest

android:windowSoftInputMode="adjustPan"
joao86
  • 2,056
  • 1
  • 21
  • 23
  • by adding that, this happens: http://imgur.com/a/y4Wdv - everything scrolls up and there are hidden unreachable tasks below the keyboard – koichirose Aug 30 '17 at 08:09
  • They are not unreachable: if you have a scrollView you must be able to scroll or you push the next button at the bottom right (>) or you close the keyboard (down arrow). These are the only options you have. – joao86 Aug 30 '17 at 10:09
  • Isn't there a way to resize the scrollView so that when the keyboard is open I can scroll to see all items? Right now, if I tap on a bottom item, the keyboard opens and I can scroll all items. If I tap on a top item it won't let me see the bottom items (they will be behind the keyboard) – koichirose Aug 30 '17 at 10:48
  • I saw these options: ` android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan"` and `android:windowSoftInputMode="adjustResize"` here: https://stackoverflow.com/questions/12422566/adjust-scrollview-when-keyboard-is-up – joao86 Aug 30 '17 at 10:57