I'm super new to Android -
I've dropped in a scrollview on my screen and am just placing some text inside of it. I'm doing this because on some phones the text runs off the screen.
The problem I'm having is that the scrollview I've dropped onto the page is longer than the content it holds -- the more narrow the phone screen is, the longer the scrollview.
<?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="wrap_content"
android:fillViewport="true" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/app_background"
android:orientation="vertical"
android:padding="10dp" >
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="20"
android:inputType="textMultiLine"
android:lineSpacingExtra="3dp"
android:text="Get ready to melt fat and burn calories with Fit Body Boot Camp's 14 Day Fat Furnace Workout Program! This is a detailed 14 Day Workout plan based on Fit Body Boot Camp's Unstoppable Fitness Formula that has been implemented in close to 300 boot camps worldwide by hundreds of thousands of clients who made the decision to lose weight and get healthier."
android:textColor="#FFF"
android:textColorLink="#FFF"
android:textSize="20sp" >
</EditText>
There are some more edittexts after this one, but this is the gist of it. Let me know if you see something stupid.
Your background is in the linear layout that is in the ScrollView. If you put the scroll view in another linear layout that is parent to the ScrollView and contains the background and remove the background from the Linear layout that is a child to the Scroll View the issue will be solved.
It will look like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/app_background" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp" >
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="20"
android:inputType="textMultiLine"
android:lineSpacingExtra="3dp"
android:text="THE LONG TEXT YOU'VE TYPED"
android:textColor="#FFF"
android:textColorLink="#FFF"
android:textSize="20sp" >
</EditText>
</LinearLayout>
</ScrollView>
</LinearLayout>
I think scrollview should fill the parent, and children views wrap content since layout_height is the size that the view will actually have on the screen, the scrolling thing happens inside the view
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
//...
android:layout_height="fill_parent"
//...
>
EDIT
as pointed out by dbalaouras better use "match_parent" instead of "fill_parent" since the latter is deprecated. The result is the same, just the name has been changed just because "fill" was confusing, if you set that it won't fill the remaining space but just set the dimension according to its parent
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