Android: Scrollview Stretches Background Image

So, I'm trying to make my activity scrollable, and when I put my relativity in the scroll, this happens:

enter image description here

This is the code of the screenshot above:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/background"
        android:orientation="vertical"
        android:paddingLeft="60dp"
        android:paddingTop="53dp" >

        <ImageView
            android:id="@+id/gearImage"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_marginTop="70dp"
            android:clickable="true"
            android:contentDescription="@string/gearDescription_string"
            android:src="@drawable/gear" />
    </RelativeLayout>

</ScrollView>

If I choose to scroll, it will be correct, but, of course, without the scroll function that I want:

enter image description here

Now I can make it look like this:

enter image description here

So I can still scroll, but if they get to the bottom of the background image, then I'm just white (it's hard to say because the background of the webpage is white, but I added a white rectangle at the bottom of the second image to show what I have in mind). In any case, there would be no reason for them to bottom.

, , scrollview , .

.

+5
5

, , , . , scrollview , . , , , , .

, . , , scrollview.

+1

android:fillViewport. , defines whether the scrollview should stretch its content to fill the viewport. ScrollView:

android:fillViewport="true"

, .

EDIT:

:

  • ScrollView android:layout_height="fill_parent"
  • RelativeLayout android:layout_height="wrap_content"
+6

, :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rel"  
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroll" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:background="@drawable/login_background"
    android:fillViewport="true"
    >

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
   android:orientation="vertical"
  >
+2

RelativeLayout ScrollView. <RelativeLayout> <ScrollView>:

android:background="@drawable/background"

, , RelativeLayout. .

0

This fixed the problem for me

Add this line to the corresponding activity in the manifest file

android:windowSoftInputMode="adjustResize" 
0
source

All Articles