Comparison of code, Final result and Layout Validation
I'm trying to generate a Button on the bottom of the Screen, First I use a linear layout for the other elements of the data recollecting program, it uses two other layouts to generate an auto-sizing list, everything is working well with exception of the last button that appears in the Layout Validation but when I run it, it disappears.
enter code here
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:id="#+id/ly1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="9"
android:orientation="vertical">
<TextView
android:id="#+id/txN1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margeny_1"
android:text="#string/nombre"
android:textColor="#color/primary_text"
android:textSize="#dimen/texto_2" />
<EditText
android:id="#+id/txN2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="username"
android:background="#color/divider"
android:inputType="text"
android:textColor="#color/secondary_text"
android:textSize="#dimen/textos_1" />
<TextView
android:id="#+id/txf1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margeny_1"
android:text="#string/fecha"
android:textColor="#color/primary_text"
android:textSize="#dimen/texto_2" />
<TextView
android:id="#+id/txf2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/divider"
android:textColor="#color/secondary_text"
android:textSize="#dimen/textos_1" />
<Button
android:id="#+id/btf1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margeny_2"
android:text="#string/deffecha"
android:theme="#style/Button1" />
<TextView
android:id="#+id/txT1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margeny_1"
android:text="#string/telefono"
android:textColor="#color/primary_text"
android:textSize="#dimen/texto_2" />
<EditText
android:id="#+id/edT1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="Phone"
android:background="#color/divider"
android:inputType="phone"
android:textColor="#color/secondary_text"
android:textSize="#dimen/textos_1" />
<TextView
android:id="#+id/txE1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/email"
android:textColor="#color/primary_text"
android:textSize="#dimen/texto_2" />
<EditText
android:id="#+id/edE1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/divider"
android:inputType="textEmailAddress"
android:textColor="#color/secondary_text"
android:textSize="#dimen/textos_1" />
<TextView
android:id="#+id/txDC1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/descripcion"
android:textColor="#color/primary_text"
android:textSize="#dimen/texto_2" />
<EditText
android:id="#+id/edDC1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoSizeTextType="uniform"
android:background="#color/divider"
android:inputType="text"
android:textColor="#color/secondary_text"
android:textSize="#dimen/textos_1" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/btSig"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="0dp"
android:baselineAligned="false"
android:text="Siguiente"
android:theme="#style/Button1"
app:layout_constraintBottom_toBottomOf="#+id/linearLayout"
/>
</LinearLayout>
I don't know why and how You want to auto-resize content but I make something like this:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/btSig"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/txN1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="nombre" />
<EditText
android:id="#+id/txN2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="username"
android:inputType="text" />
<TextView
android:id="#+id/txf1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="fecha" />
<TextView
android:id="#+id/txf2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="4" />
<Button
android:id="#+id/btf1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="deffecha" />
<TextView
android:id="#+id/txT1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="telefono" />
<EditText
android:id="#+id/edT1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="Phone"
android:inputType="phone" />
<TextView
android:id="#+id/txE1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="email" />
<EditText
android:id="#+id/edE1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress" />
<TextView
android:id="#+id/txDC1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/edDC1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoSizeTextType="uniform"
android:inputType="text" />
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/btSig"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:text="Siguiente"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
(Of course, I change strings and dimension values)
It looks like that:
One button is always on the bottom of the screen and the rest in scroll view.
Related
I have the following layout for my dialog:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="#string/practice_question" />
<TextView
android:id="#+id/dialog_select_question"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textColor="#color/primary_text"
android:textSize="16sp"
tools:ignore="RtlHardcoded" />
<ListView
android:id="#+id/dialog_select_answers"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="#+id/dialog_select_board_button"
style="?attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="#string/practice_look_board" />
<Button
android:id="#+id/dialog_select_answer_button"
style="?attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="#string/practice_answer" />
</LinearLayout>
</LinearLayout>
There is a problem with bottom buttons:
I want the first button not to be cropped. I've set android:layout_height="wrap_content" but that doesn't helped.
P.S. If I change button text from "Look on the board" to "Look on the\nboard" all works fine. But I want to make the second button optional, so the first button may match the whole parent's width.
I have changed some of your code please try this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/dialog_select_title"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="#string/practice_question" />
<TextView
android:id="#+id/dialog_select_question"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/dialog_select_title"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textColor="#color/primary_text"
android:textSize="16sp"
tools:ignore="RtlHardcoded" />
<ListView
android:id="#+id/dialog_select_answers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/dialog_select_question" />
<LinearLayout
android:id="#+id/dialog_select_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/dialog_select_answers"
android:orientation="horizontal">
<Button
android:id="#+id/dialog_select_board_button"
style="?attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="#string/practice_look_board" />
<Button
android:id="#+id/dialog_select_answer_button"
style="?attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="#string/practice_answer" />
</LinearLayout>
</RelativeLayout>
I have designed a signup screen in which I have a Scroll view , But Scroll view is not working.
I am not able to find why Scroll is not working , Help me with this.
Below is the code for reference:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/tool_bar"
layout="#layout/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="#+id/sign_up_profile_image"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="#drawable/shape_rectangle_rounded_corner"
android:padding="10dp"
android:scaleType="fitXY"
android:src="#drawable/icon_avatar" />
<RelativeLayout
android:id="#+id/container_two"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/container_three"
android:layout_below="#+id/sign_up_profile_image"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="20dp"
android:orientation="vertical">
<LinearLayout
android:id="#+id/first_last_name_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<ui.customviews.MaterialEditText
android:id="#+id/sign_up_first_name_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_marginTop="2dp"
android:layout_weight="50"
android:hint="#string/first_name_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:textSize="18sp"
app:baseColor="#363636"
app:floatingLabel="normal"
app:primaryColor="#000000" />
<customviews.MaterialEditText
android:id="#+id/sign_up_last_name_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:layout_marginTop="2dp"
android:layout_weight="50"
android:hint="#string/last_name_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:textSize="18sp"
app:baseColor="#363636"
app:floatingLabel="normal"
app:primaryColor="#000000" />
</LinearLayout>
<ui.customviews.MaterialEditText
android:id="#+id/sign_up_email_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/first_last_name_container"
android:hint="#string/email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:textSize="18sp"
app:baseColor="#363636"
app:floatingLabel="normal"
app:primaryColor="#000000"
/>
<ui.customviews.MaterialEditText
android:id="#+id/sign_up_password_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/sign_up_email_edit_text"
android:hint="#string/password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:textSize="18sp"
app:baseColor="#363636"
app:floatingLabel="normal"
app:primaryColor="#000000" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/container_three"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="#dimen/activity_vertical_margin">
<TextView
android:id="#+id/sign_up_terms_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:gravity="center_horizontal"
android:lineSpacingExtra="2dp"
android:lineSpacingMultiplier="1.2"
android:text="By signing up, you accept to the Terms and Conditions and Privacy Policy"
android:textColor="#6b6b6b"
android:textSize="14sp" />
<Button
android:id="#+id/sign_up_accept_button"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/sign_up_terms_text_view"
android:layout_marginLeft="#dimen/activity_vertical_margin"
android:layout_marginRight="#dimen/activity_vertical_margin"
android:background="#025961"
android:text="#string/accept_and_signup"
android:textColor="#android:color/white"
android:textSize="14sp" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
Try Like this, Add inside Linear layout , it will Scroll till End of the Page.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
// Your xml Code Put Here
</LinearLayout>
</ScrollView>
</Relativelayout>
solution can be change ScrollView to:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
>
Then you should change nested's layout height as well
I am trying to add 3 or more lists in a layout xml. I didn't expect this to be a problem, but I don't see all the lists(and they get populated) and the view does not scroll. I need an opinion to what stupid stuff I am doing here, please.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/googleDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white" >
<RelativeLayout
android:id="#+id/navigationHeader"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#drawable/wallpaper"
android:paddingTop="16dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="#dimen/activity_horizontal_margin"
android:orientation="vertical" >
<EditText
android:id="#+id/searchTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Search" />
<TextView
android:id="#+id/txtUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/holo_green_light"
android:text="Hello, user"
android:textColor="#android:color/white"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/holo_blue_light"
android:text="description"
android:textColor="#android:color/white" />
</LinearLayout>
</RelativeLayout>
<ScrollView
android:id="#+id/scrollojt"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/navigationHeader"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/activity_horizontal_margin" >
<View
android:id="#+id/separator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:background="#1f000000" />
<TextView
android:id="#+id/questionsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/separator"
android:text="#string/questions_label"
android:textAllCaps="true"
android:textColor="#android:color/black" />
<ListView
android:id="#+id/drawerList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/questionsTitle"
android:background="#android:color/holo_green_dark"
android:clickable="true"
android:focusableInTouchMode="true"
android:scrollbars="vertical" />
<TextView
android:id="#+id/appsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/drawerList"
android:text="#string/apps_label"
android:textAllCaps="true"
android:textColor="#android:color/black" />
<ListView
android:id="#+id/drawerList2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/appsTitle"
android:background="#android:color/holo_red_dark"
android:clickable="true"
android:focusableInTouchMode="true"
android:scrollbars="vertical" />
<TextView
android:id="#+id/groupsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/drawerList2"
android:text="#string/groupapps_label"
android:textAllCaps="true"
android:textColor="#android:color/black" />
<ListView
android:id="#+id/drawerList3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/groupsTitle"
android:background="#android:color/holo_blue_bright"
android:clickable="true"
android:focusableInTouchMode="true"
android:scrollbars="vertical" />
<TextView
android:id="#+id/dmTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/drawerList3"
android:text="#string/directapps_label"
android:textAllCaps="true"
android:textColor="#android:color/black" />
<ListView
android:id="#+id/drawerList4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/dmTitle"
android:background="#android:color/holo_green_light"
android:clickable="true"
android:focusableInTouchMode="true"
android:scrollbars="vertical" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Use just one ListView with an ArrayAdapter.
how to use arrayadapter
If you need help customizing the array adapter, just search on google or ask me ;)
I use the following layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp"
android:isScrollContainer="true">
<TextView
android:id="#+id/wizard4_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:scrollbars="vertical"
android:text="#string/wizard4_title"
android:textColor="#0088cc"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="0dp"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:id="#+id/wizard4_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="fill_horizontal"
android:scrollbars="vertical"
android:text="#string/wizard4_text1"
android:textSize="18sp" />
<EditText
android:id="#+id/wizard4_name"
android:hint="#string/wizard4_name_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/wizard4_text3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="fill_horizontal"
android:scrollbars="vertical"
android:text="#string/wizard4_text3"
android:textSize="18sp" />
<EditText
android:id="#+id/wizard4_address"
android:hint="#string/wizard4_address_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<Button
android:id="#+id/wizard4_btn_back"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/wizard_back" />
<Button
android:id="#+id/wizard4_btn_next"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/wizard_next" />
</LinearLayout>
</LinearLayout>
It is displayed as part of ViewAnimator:
viewAnimator = new ViewAnimator(this);
...
View step4 = View.inflate(getBaseContext(), R.layout.wizard4, null);
viewAnimator.addView(step4);
setContentView(viewAnimator);
When user clicks on the second input field (wizard4_address), soft keyboard is display, which hides the input field. Currently buttons wizard4_btn_next and wizard4_btn_back are also displayed when keyboard is shown, I don't need it. But I should keep them always at the bottom.
Try this. Hope you will get what you want.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/wizard4_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:scrollbars="vertical"
android:text="#string/wizard4_title"
android:textColor="#0088cc"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/wizard4_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="fill_horizontal"
android:scrollbars="vertical"
android:text="#string/wizard4_text1"
android:textSize="18sp" />
<EditText
android:id="#+id/wizard4_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/wizard4_name_hint" />
<TextView
android:id="#+id/wizard4_text3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="fill_horizontal"
android:scrollbars="vertical"
android:text="#string/wizard4_text3"
android:textSize="18sp" />
<EditText
android:id="#+id/wizard4_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/wizard4_address_hint" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" >
<Button
android:id="#+id/wizard4_btn_back"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/wizard_back" />
<Button
android:id="#+id/wizard4_btn_next"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/wizard_next" />
</LinearLayout>
I have a ScrollView with some widgets in it, amongst them an EditText. When I write a couple of lines in the EditText (id:message), I can't scroll the ScrollView all the way up to the top, it is stuck until I close the soft keyboard. After that, if I go into the EditText again and write another couple of lines, this doesn't happen anymore. This only happens on Android 4.x, not on 2.3.
How can I prevent my ScrollView from getting stuck?
Here's my layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingTop="#dimen/activity_vertical_margin" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<EditText
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/ihr_name"
android:imeOptions="flagNoExtractUi"
android:inputType="textPersonName"
android:singleLine="true" >
</EditText>
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:hint="#string/ihre_email"
android:imeOptions="flagNoExtractUi"
android:inputType="textEmailAddress"
android:singleLine="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" >
<asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton
android:id="#+id/startDate"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/starterror"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:background="#00000000" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" >
<asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton
android:id="#+id/endDate"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/enderror"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:background="#00000000" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" >
<asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton
android:id="#+id/xy"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/adulterror"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:background="#00000000" />
</RelativeLayout>
<asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton
android:id="#+id/tre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="24dp"
android:text="Message: "
android:textAppearance="#style/StandardTextBold"
android:textColor="#color/myorange" />
<EditText
android:id="#+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:hint="#string/ihre_nachricht"
android:inputType="textNoSuggestions|textMultiLine"
android:text="#string/contact_message" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/pflichtfelder"
android:textAppearance="#style/SmallText" />
<Button
android:id="#+id/send"
style="#style/ButtonTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Senden" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/contact_datenschutz"
android:textAppearance="#style/SmallText" />
</LinearLayout>
</ScrollView>
Here's a screenshot of the stuck layout (not too interesting probably):
Your input options are set to pan (keep the view we are inputting visible)
add android:windowSoftInputMode="adjustResize" to your activity declaration in the manifest