ScrollView with RelativeLayout

0

How do I RelativeLayout occupy the full height of the screen within ScrollView ? (I tried wrap_contet but as I have AdMob ad it gives an error with the button)

Code:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"
    tools:context="alcoolougasolina.aplicativo.MainActivity"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true">


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="400dp">


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="Descubra qual combustivel é mais vantajoso abastecer."
                android:id="@+id/textView3"
                android:layout_alignParentTop="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_marginTop="20dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp" />


            <com.google.android.gms.ads.AdView
                android:id="@+id/adView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                ads:adSize="BANNER"
                ads:adUnitId="ca-app-pub-7380991228143623/3071936395"
                android:layout_alignParentTop="false"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true">
            </com.google.android.gms.ads.AdView>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="Preço Gasolina:"
                android:id="@+id/textView"
                android:layout_below="@+id/textView3"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_marginTop="20dp" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="numberDecimal"
                android:ems="10"
                android:id="@+id/editText"
                android:layout_below="@+id/textView"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_marginTop="0dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:text="@string/edt1" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="Preço Álcool:"
                android:id="@+id/textView2"
                android:layout_below="@+id/editText"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_marginTop="25dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="numberDecimal"
                android:ems="10"
                android:id="@+id/editText2"
                android:layout_below="@+id/textView2"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:text="@string/edt2" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/bt1"
                android:id="@+id/Calcular"
                android:layout_below="@+id/editText2"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="30dp"
                android:onClick="calculo"
                android:layout_marginBottom="30dp" />


        </RelativeLayout>
    </LinearLayout>
</ScrollView>

Image:

    
asked by anonymous 20.08.2016 / 18:15

1 answer

1

You have to let your ScrollView occupy all of the screen space by changing its height to match_parent , then all content that is inside

  

match_parent : The View should take up the same space as your Parent View   (View Parent). In any dimension (height and / or width)

     

fill_parent : Same match_parent function, but was used in   android 2.1, when the update was made for 2.3, was discontinued in   use of match_parent.

     

wrap_content : The View should occupy only the space you need (height   and / or width) to display your information in the layout.

The attributes of ScrollView would look like this, occupying all space vertically, as well as horizontally:

android:layout_width="wrap_content"
android:layout_height="match_parent"

See the image below:

    
20.08.2016 / 18:33