i have to develope an app in fullscreen mode and now i have a formular with some textEdits and some buttons. If the keyboard pops up it hides two buttons so i put everything into a scrollview:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
tools:context="controller.RegsiterActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/register_textview_firstname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:singleLine="true"
android:text="@string/text_firstname" />
<EditText
android:id="@+id/register_textedit_firstname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:inputType="text" />
<TextView
android:id="@+id/register_textview_lastname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:singleLine="true"
android:text="@string/text_lastname" />
<EditText
android:id="@+id/register_textedit_lastname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:inputType="text" />
<TextView
android:id="@+id/register_textview_email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:singleLine="true"
android:text="@string/text_email" />
<EditText
android:id="@+id/register_textedit_email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:inputType="textEmailAddress" />
<TextView
android:id="@+id/register_text_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:singleLine="true"
android:text="@string/text_password" />
<EditText
android:id="@+id/register_textedit_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:inputType="text" />
<Button
android:id="@+id/register_button_register"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/button_register" />
<Button
android:id="@+id/register_button_cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/button_cancel" />
</LinearLayout>
</ScrollView>
As i said i have to run my app in fullscreen:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
But when i now run my app no scrollView appears and no scrolling is working.
How can i make the scrollView work?
First attribute you should probably add to the ScrollView
is:
android:fillViewport="true"
When set to true, this attribute causes the scroll view’s child to expand to the height of the ScrollView if needed. When the child is taller than the ScrollView, the attribute has no effect.
Also, change the fill_parent
layout dimensions to match_parent
because fill_parent
is deprecated and you can get rid of any annoying warnings.
Further, change the layout_height
attribute of the LinearLayout
to match_parent
so it will resize together with the ScrollView
on screen configuration changes such as pulling up the keyboard.
Also, similarly to @karvoynistas suggestion, you should take a look at windowSoftInputMode
property.
You can add this property to your activity:
<activity
android:windowSoftInputMode="stateVisible|adjustResize"
...>
<!-- ... -->
</activity>
The effect of this is (according to Android docs
):
To ensure that the system resizes your layout to the available space—which ensures that all of your layout content is accessible (even though it probably requires scrolling)
Adding the adjustPan
value to the windowSoftInputMode
attribute could work but not be exactly what you want since it might cause some unusual affect (read bellow).
Android Docs comparison of the two values:
adjustResize
The activity's main window is always resized to make room for the soft keyboard on screen.
adjustPan
The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With