Adjust the edit text to take full screen scroll mode

I have an EditText field inside a LinearLayout that is in scrollview. As long as ScrollView does not exist, layout_weight="1.0" allows my EditText to take up the remaining screen. But as soon as I finish LinearLayout in ScrollView , it changes EditText by one line, and layout_weight doesn't work.

My full layout file

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/titleTextView" style="@style/TitleHeaderBarText" android:text="@string/announcement" /> <ScrollView android:layout_width="match_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical" android:gravity="right" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Subject:" android:textSize="16sp" /> <EditText android:id="@+id/et_subject" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Announcement:" android:textSize="16sp" /> <EditText android:id="@+id/et_announcement" android:layout_width="match_parent" android:layout_height="fill_parent" android:layout_weight="1.0" /> <Button android:id="@+id/btn_save" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="24sp" android:paddingRight="24dp" android:text="Save" /> </LinearLayout> </ScrollView> </LinearLayout> 

I don't seem to understand what I'm doing wrong. Any suggestions, please, on how to get EditText to occupy the rest of the screen from LinearLayout , which is in ScrollView .

Thanks.

EDIT Repeating the same problem and this is my 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="match_parent" android:orientation="vertical" > <TextView android:id="@+id/titleTextView" style="@style/TitleHeaderBarText" android:text="@string/login_title" /> <ScrollView android:id="@+id/sv_weight_tell_us" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_light_radial_pink" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:padding="12dp" android:orientation="vertical" > <TextView android:id="@+id/login_header" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Login" /> <TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:stretchColumns="1" > <TableRow> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="20dp" android:text="@string/username" /> <EditText android:id="@+id/et_username" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </TableRow> <TableRow> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/password" /> <EditText android:id="@+id/et_password" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textPassword" /> </TableRow> <TableRow> <View/> <Button android:id="@+id/btn_login" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/login" android:padding="12dp" /> </TableRow> </TableLayout> <ProgressBar android:id="@+id/pb_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminate="true" style="?android:attr/progressBarStyleSmall" android:visibility="invisible" /> <TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1.0" android:gravity="bottom" android:text="@string/dont_have_Q" /> <TextView android:id="@+id/tv_sign_up" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sign_up_" /> </LinearLayout> </ScrollView> </LinearLayout> 
+4
source share
1 answer

You need to add the attribute ScrollView android:fillViewport="true" :

 ... <ScrollView android:id="@+id/sv_weight_tell_us" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_light_radial_pink" android:fillViewport="true" > .... 
+14
source

All Articles