Move views up when keyboard shows up



I recently wrote two small apps, both with the same function, one is free with ads and the other one is paid without ads.


Now I noticed following behavior:


In the free version with ads:


When clicking on an EditText view, the EditText View, the FAB button and the ad shift up, making it easier for the user to click the button whilst typing something:


enter image description here


In the paid version without ads:


When clicking on the EditText view, the entire screen shifts up a bit (take a look at the statusbar, the ActionBar elements are underneath the Statusbar elements). Only the clicked EditText Box moves up, the button below doesn't:


enter image description here


Now I'd like to know how to move up the pink button, so that it's visible when the keyboard is shown. I don't know why it does work in the ad version, probably because the ad is programmed so that it's always shown but I don't know how to reproduce this with my button in the ad free version.


Here comes the layout.xml. Note that the ad is in another layout, containing the ad itself (in the free version) and a viewpager which shows the fragment. Here is the fragment layout:


fragment_convert.xml



<?xml version="1.0" encoding="utf-8"?>



<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/fragment_convert_body"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<EditText
android:id="@+id/fragment_convert_hex"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:hint="@string/hex"
android:singleLine="true"
android:textColor="@color/white"/>
<EditText
android:id="@+id/fragment_convert_rgb"
android:layout_marginStart="22dp"
android:layout_marginLeft="22dp"
android:layout_width="130dp"
android:singleLine="true"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:hint="@string/rgb"/>
<View
android:visibility="gone"
android:id="@+id/fragment_convert_indicator"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="@color/white"
android:layout_marginStart="12dp"
android:layout_marginLeft="12dp"/>
</LinearLayout>

<com.melnykov.fab.FloatingActionButton
android:id="@+id/fragment_convert_convertbutton"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="bottom|center_horizontal"
android:background="@drawable/copy_button_background"
android:src="@drawable/ic_convert"
android:layout_margin="16dp"
fab:fab_colorPressed="@color/accent_dark"
fab:fab_colorNormal="@color/accent"/>

</FrameLayout>


Any suggestions how to make the button move up when editing a text?


No comments:

Post a Comment