Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android scrollview not filling parent view

Tags:

I have the following layout that contains a scrollview. After screen sizes greater than around 4.8" there is a white area at the bottom of the view. Why is this, when i have specified the scrollview to fill_parent?

Thanks in advance.

NB you can't see the white space below the menu on the screenshot below as it's white, sorry. There is a bout a n inch or 2 of space

 <?xml version="1.0" encoding="utf-8"?>        <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         >        <LinearLayout          android:id="@+id/ll1"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:background="@drawable/carefreebgscaledlighting"         android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">             <TextView             android:id="@+id/textviewcompanyname"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:textAppearance="?android:attr/textAppearanceLarge"             android:textColor="#003F87" />          <TextView             android:id="@+id/textViewYouAreSignedIn"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_centerInParent="true"             android:layout_alignParentTop="true"             android:textAppearance="?android:attr/textAppearanceLarge"             android:textColor="#003F87"              />                <TextView             android:id="@+id/textViewUnsentTransactions"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_centerInParent="true"             android:layout_below="@id/textViewYouAreSignedIn"             android:textAppearance="?android:attr/textAppearanceLarge"             android:textColor="#003F87"              />          <TextView             android:id="@+id/spacerasnexttextviewclasheswithbg"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:textAppearance="?android:attr/textAppearanceLarge"              />          <LinearLayout              android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:orientation="horizontal" >              <ImageView                  android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:id="@+id/imagesignaltower"                 android:background="@drawable/signaltower"/>              <ProgressBar             android:id="@+id/progressBarSignal"             style="?android:attr/progressBarStyleHorizontal"             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:progressDrawable="@drawable/progressbar2"             android:layout_marginTop="10dp" />          </LinearLayout>           <TextView             android:id="@+id/textview1"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:text="@string/stringloggedinscreen"             android:textAppearance="?android:attr/textAppearanceLarge"             android:textColor="#003F87" />      <Button         android:id="@+id/buttonsignin"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:text="@string/stringbuttonsignin"          />  ......... ........... ........... </LinearLayout>     </ScrollView> 

.

enter image description here

like image 893
turtleboy Avatar asked Oct 18 '13 08:10

turtleboy


People also ask

How do I get scroll view with match parent?

Try adding android:fillViewport="true"to your ScrollView To work around this, you need to use the ScrollView attribute called android:fillViewport. When set to true, this attribute causes the scroll view's child to expand to the height of the ScrollView if needed.

How to implement scroll view in android?

In Android, a ScrollView is a view group that is used to make vertically scrollable views. A scroll view contains a single direct child only. In order to place multiple views in the scroll view, one needs to make a view group(like LinearLayout) as a direct child and then we can define many views inside it.

Which XML attribute do you use to define the width of the linear layout inside the scrolling view?

When adding a LinearLayout inside a ScrollView , use match_parent for the LinearLayout android:layout_width attribute to match the width of the parent ScrollView , and use wrap_content for the LinearLayout android:layout_height attribute to make it only large enough to enclose its contents.


2 Answers

add to your ScrollView:

android:fillViewport="true" 
like image 119
Carnal Avatar answered Oct 15 '22 14:10

Carnal


try to set ScrollView android:fillViewport="true" , refer to this

like image 20
jaredzhang Avatar answered Oct 15 '22 12:10

jaredzhang