ScrollView containing RelativeLayout

0

When I put my App in landscape mode, it cuts off some of the information. So I need to put a ScrollView . However, I already searched in several sites and even in the documentation but still I can not make it work. Can anyone help me?

<?xml version="1.0" encoding="utf-8"?>

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <RelativeLayout
        android:id="@+id/container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:id="@+id/cabecalho"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#0097A7"
            android:fontFamily="cursive"
            android:gravity="center_horizontal"
            android:text="Pousada George's Village"
            android:textColor="#FFFFFF"
            android:textSize="30sp"
            android:textStyle="bold|italic"/>

        <ImageView
            android:id="@+id/georges"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@id/local"
            android:layout_below="@id/cabecalho"
            android:scaleType="centerCrop"
            android:src="@drawable/georges"/>

        <ImageView
            android:id="@+id/local"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:padding="16dp"
            android:src="@drawable/local"/>

        <ImageView
            android:id="@+id/fone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/local"
            android:paddingLeft="16dp"
            android:paddingRight="16dp"
            android:paddingBottom="16dp"
            android:src="@drawable/telefone"/>

        <ImageView
            android:id="@+id/site"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/fone"
            android:paddingLeft="16dp"
            android:paddingRight="16dp"
            android:paddingBottom="16dp"
            android:src="@drawable/site"/>

        <ImageView
            android:id="@+id/email"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/site"
            android:paddingLeft="16dp"
            android:paddingRight="16dp"
            android:paddingBottom="16dp"
            android:src="@drawable/email"/>

        <TextView
            android:id="@+id/localizacao"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/georges"
            android:layout_toRightOf="@id/local"
            android:paddingTop="8dp"
            android:text="Av. Ver. Manoel dos Santos, 195 - Centro, Bombinhas - SC, 88215-000."
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000000"/>

        <TextView
            android:id="@+id/texto_fone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/local"
            android:layout_toRightOf="@id/fone"
            android:text="(47) 3369-2177."
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000000"/>

        <TextView
            android:id="@+id/texto_site"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/fone"
            android:layout_toRightOf="@id/site"
            android:text="https://www.georgesvillage.com.br"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000000"/>

        <TextView
            android:id="@+id/texto_email"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/site"
            android:layout_toRightOf="@id/email"
            android:text="[email protected]"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000000"/>

        <TextView
            android:id="@+id/texto_hotel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/email"
            android:paddingLeft="16dp"
            android:paddingRight="16dp"
            android:paddingBottom="16dp"
            android:text="Este hotel informal com vista para o Oceano Atlântico está distribuído em vários prédios cercados por florestas tropicais, fica a 6 minutos a pé da Praia de Bombinhas e a 19 km da rodovia federal BR-101."
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#000000"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/texto_hotel"
            android:layout_alignParentRight="true"
            android:padding="5dp"
            android:text="By: R.A.O."
            android:textSize="7sp"
            android:textStyle="italic"/>

    </RelativeLayout>

</ScrollView>
    
asked by anonymous 16.10.2018 / 18:31

1 answer

0

Uses NestedScrollView , as the name suggests is used when there is a need for a scrolling view within another scrolling view. Usually, this would be difficult to accomplish, since the system could not decide which visualization should be rolled. This is where NestedScrollView comes in, that is, it only scrolls when you need it.

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="center"
android:orientation="vertical">

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_margin="20dp"
    android:background="@android:color/white"
    android:padding="10dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/nested_scroll_text"/>

    </RelativeLayout>

</android.support.v4.widget.NestedScrollView>
    
17.10.2018 / 18:56