White at the bottom of the screen with Scrollview

Asked

Viewed 50 times

-1

I put a ScrollView in one of my layouts, to allow users with smaller screens to view all information.

The problem is that when I start the application on my mobile phone (5.5') I see a white band above the layout:

inserir a descrição da imagem aqui

The code xml of layout is as follows:

 <ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:overScrollMode="ifContentScrolls"
    android:fillViewport="true"

    >
<RelativeLayout
    android:id="@+id/activity_main_apresentation"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorBackGround">


    <ImageView
        android:id="@+id/imagetoMain"
        android:layout_width="wrap_content"
        android:layout_height="400dp"
        android:contentDescription="ola"
        android:src="@drawable/cakelogomain"

        />


    <TextView
        android:id="@+id/txttoDescription"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/imagetoMain"
        android:layout_centerHorizontal="true"
        android:text="@string/description"
        android:textColor="@color/colorSecondBackGround"
        android:textSize="18sp"
        android:textStyle="bold" />


    <TextView
        android:id="@+id/texttoViewTodscr"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txttoDescription"
        android:gravity="center_horizontal"
        android:text="@string/descriptionTwo"
        android:textColor="@color/colorSecondBackGround"
        android:textSize="10sp" />

    <Button
        android:id="@+id/idButton"
        android:layout_width="350dp"
        android:layout_height="wrap_content"
        android:layout_below="@id/texttoViewTodscr"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:background="@color/colorSecondBackGround"
        android:text="@string/botaoMainTransition"
        android:textColor="@color/colorWhite" />



</RelativeLayout>

</ScrollView>

Can someone give me an explanation of why this happened?

Some better way to adapt mine layouts to smaller screens?

1 answer

2


Try setting the Scrollview height to take the whole screen, example:

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:overScrollMode="ifContentScrolls"
    android:fillViewport="true"

Alters to:

<ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
  • Thank you Leonardo! It worked, a small detail that completely passed me by! This is the best way to present on small screens, or know another? :)

  • 1

    I believe it’s the best way, the match_parent will cause the screen to adapt to the user’s screen both in width and height, and putting the scroll bar only when necessary, if someone opens with a 6 inch device, it may be that the scroll bar does not even appear

  • Thanks for the help Leonardo! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.