Layout does not occupy full screen

1

I'm putting together a layout and the layout is not occupying the entire screen. I have tried it in many ways, but it is never possible for it to occupy, so everything I need is not fit.

Problem happens when placing the scrollview, is it possible to have the whole screen with it?

Follow XML:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    android:id="@+id/relative_rota">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_vertical"
        android:orientation="vertical"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="15dp">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="0dp"
            android:layout_marginStart="@dimen/txt_left_margin"
            android:layout_marginTop="@dimen/first_view_top_margin"
            android:fontFamily="sans-serif-condensed"
            android:text="@string/ondeEstou"
            android:textColor="@color/txt_text"
            android:textStyle="bold" />


        <AutoCompleteTextView
            android:id="@+id/rota_edt_origem"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="7dp"
            android:layout_marginEnd="@dimen/edt_right_margin"
            android:layout_marginStart="@dimen/edt_left_margin"
            android:layout_marginTop="@dimen/edt_top_margin"
            android:fontFamily="sans-serif-condensed"
            android:hint="@string/action_my_location"
            android:inputType="textCapCharacters"
            android:maxLines="1"
            android:singleLine="true"
            android:textColor="@color/edt_text"
            android:textColorHint="@color/edt_text"
            android:textSize="@dimen/edt_text_size" />


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/txt_left_margin"
            android:fontFamily="sans-serif-condensed"
            android:text="@string/destino"
            android:textColor="@color/txt_text"
            android:textStyle="bold" />

        <AutoCompleteTextView
            android:id="@+id/rota_edt_destino"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/edt_right_margin"
            android:layout_marginStart="@dimen/edt_left_margin"
            android:layout_marginTop="@dimen/edt_top_margin"
            android:fontFamily="sans-serif-condensed"
            android:inputType="textCapCharacters"
            android:hint="@string/action_type_destination"
            android:maxLines="1"
            android:singleLine="true"
            android:textColor="@color/edt_text"
            android:textColorHint="@color/edt_text"
            android:textSize="@dimen/edt_text_size"
            android:layout_marginBottom="7dp"/>


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/txt_left_margin"
            android:fontFamily="sans-serif-condensed"
            android:text="@string/companhia"
            android:textColor="@color/txt_text"
            android:textStyle="bold" />

        <EditText
            android:id="@+id/rota_edt_companhia"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="7dp"
            android:layout_marginEnd="@dimen/edt_right_margin"
            android:layout_marginStart="@dimen/edt_left_margin"
            android:layout_marginTop="@dimen/edt_top_margin"
            android:fontFamily="sans-serif-condensed"
            android:inputType="none"
            android:maxLines="1"
            android:singleLine="true"
            android:textColor="@color/edt_text"
            android:textIsSelectable="true"
            android:textSize="@dimen/edt_text_size" />

    </LinearLayout>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        android:completionThreshold="3"
        android:src="@drawable/powered_by_google_light"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:gravity="center_horizontal"
        android:layout_alignParentStart="true"
        android:layout_marginTop="124dp">

        <ImageButton
            android:id="@+id/trasporte_a_pe"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:contentDescription="@string/place_autocomplete_search_hint"
            android:onClick="chamarRota"
            android:padding="@dimen/place_autocomplete_button_padding"
            android:src="@drawable/ic_transp_walk_white_48px" />

        <ImageButton
            android:id="@+id/trasporte_bike"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:contentDescription="@string/place_autocomplete_search_hint"
            android:onClick="chamarRota"
            android:padding="@dimen/place_autocomplete_button_padding"
            android:src="@drawable/ic_transp_bike_white_48px" />

        <ImageButton
            android:id="@+id/trasporte_carro"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:contentDescription="@string/place_autocomplete_search_hint"
            android:onClick="chamarRota"
            android:padding="@dimen/place_autocomplete_button_padding"
            android:src="@drawable/ic_transp_car_white_48px" />


        <ImageButton
            android:id="@+id/trasporte_publico"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:contentDescription="@string/place_autocomplete_search_hint"
            android:onClick="chamarRota"
            android:padding="@dimen/place_autocomplete_button_padding"
            android:src="@drawable/ic_transp_bus_white_48px" />

    </LinearLayout>
</RelativeLayout>

Follow the picture as it is:

Ineedyoutofilltheentirescreen,soit'swelldistributed.Onlyvertically.

Thanksforthehelp!

-EDIT-XMLchanged,butwhenIputthescrollview,soitispossibletoscrollthescreenwiththekeyboardopen,itlimitsmetotheonemarkedintheimage.

<?xmlversion="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relative_rota"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/fundo_3"
    android:padding="10dp"
    tools:context="app.Rota">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_below="@+id/layout_top"
        android:layout_gravity="end"
        android:completionThreshold="3"
        android:src="@drawable/powered_by_google_light" />

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="115dp"
        android:gravity="center_horizontal"
        android:orientation="horizontal">

        <ImageButton
            android:id="@+id/trasporte_a_pe"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:background="@color/fundo_3"
            android:contentDescription="@string/place_autocomplete_search_hint"
            android:onClick="chamarRota"
            android:padding="@dimen/place_autocomplete_button_padding"
            android:src="@drawable/ic_transp_walk_white_48px" />

        <ImageButton
            android:id="@+id/trasporte_bike"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:background="@color/fundo_3"
            android:contentDescription="@string/place_autocomplete_search_hint"
            android:onClick="chamarRota"
            android:padding="@dimen/place_autocomplete_button_padding"
            android:src="@drawable/ic_transp_bike_white_48px" />

        <ImageButton
            android:id="@+id/trasporte_carro"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:background="@color/fundo_3"
            android:contentDescription="@string/place_autocomplete_search_hint"
            android:onClick="chamarRota"
            android:padding="@dimen/place_autocomplete_button_padding"
            android:src="@drawable/ic_transp_car_white_48px" />


        <ImageButton
            android:id="@+id/trasporte_publico"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:background="@color/fundo_3"
            android:contentDescription="@string/place_autocomplete_search_hint"
            android:onClick="chamarRota"
            android:padding="@dimen/place_autocomplete_button_padding"
            android:src="@drawable/ic_transp_bus_white_48px" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/layout_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="80dp"
        android:gravity="center_vertical"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="0dp"
            android:layout_marginStart="@dimen/txt_left_margin"
            android:layout_marginTop="@dimen/first_view_top_margin"
            android:fontFamily="sans-serif-condensed"
            android:text="@string/ondeEstou"
            android:textColor="@color/txt_text"
            android:textStyle="bold" />


        <AutoCompleteTextView
            android:id="@+id/rota_edt_origem"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="7dp"
            android:layout_marginEnd="@dimen/edt_right_margin"
            android:layout_marginStart="@dimen/edt_left_margin"
            android:layout_marginTop="@dimen/edt_top_margin"
            android:fontFamily="sans-serif-condensed"
            android:hint="@string/action_my_location"
            android:inputType="textCapCharacters"
            android:maxLines="1"
            android:singleLine="true"
            android:textColor="@color/edt_text"
            android:textColorHint="@color/edt_text"
            android:textSize="@dimen/edt_text_size" />


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/txt_left_margin"
            android:fontFamily="sans-serif-condensed"
            android:text="@string/destino"
            android:textColor="@color/txt_text"
            android:textStyle="bold" />

        <AutoCompleteTextView
            android:id="@+id/rota_edt_destino"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="7dp"
            android:layout_marginEnd="@dimen/edt_right_margin"
            android:layout_marginStart="@dimen/edt_left_margin"
            android:layout_marginTop="@dimen/edt_top_margin"
            android:fontFamily="sans-serif-condensed"
            android:hint="@string/action_type_destination"
            android:inputType="textCapCharacters"
            android:maxLines="1"
            android:singleLine="true"
            android:textColor="@color/edt_text"
            android:textColorHint="@color/edt_text"
            android:textSize="@dimen/edt_text_size" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/txt_left_margin"
            android:fontFamily="sans-serif-condensed"
            android:text="@string/companhia"
            android:textColor="@color/txt_text"
            android:textStyle="bold" />

        <EditText
            android:id="@+id/rota_edt_companhia"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="7dp"
            android:layout_marginEnd="@dimen/edt_right_margin"
            android:layout_marginStart="@dimen/edt_left_margin"
            android:layout_marginTop="@dimen/edt_top_margin"
            android:fontFamily="sans-serif-condensed"
            android:inputType="none"
            android:maxLines="1"
            android:singleLine="true"
            android:textColor="@color/edt_text"
            android:textIsSelectable="true"
            android:textSize="@dimen/edt_text_size" />

    </LinearLayout>
</RelativeLayout>
    
asked by anonymous 13.01.2017 / 23:09

1 answer

2

Since I do not have your drawables and values, and you did not show exactly how you would like the layout to be, I improvised over the code. I put colors in the background of layouts (to differentiate) and used images from Studio.

Compare the two to understand where you went wrong.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:id="@+id/relative_rota">

<LinearLayout
    android:id="@+id/layout_top"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:orientation="vertical"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="15dp"
    android:background="@android:color/holo_green_dark">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="0dp"
        android:layout_marginStart="@dimen/txt_left_margin"
        android:layout_marginTop="@dimen/first_view_top_margin"
        android:fontFamily="sans-serif-condensed"
        android:text="@string/ondeEstou"
        android:textColor="@color/txt_text"
        android:textStyle="bold" />


    <AutoCompleteTextView
        android:id="@+id/rota_edt_origem"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="7dp"
        android:layout_marginEnd="@dimen/edt_right_margin"
        android:layout_marginStart="@dimen/edt_left_margin"
        android:layout_marginTop="@dimen/edt_top_margin"
        android:fontFamily="sans-serif-condensed"
        android:hint="@string/action_my_location"
        android:inputType="textCapCharacters"
        android:maxLines="1"
        android:singleLine="true"
        android:textColor="@color/edt_text"
        android:textColorHint="@color/edt_text"
        android:textSize="@dimen/edt_text_size" />


    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/txt_left_margin"
        android:fontFamily="sans-serif-condensed"
        android:text="@string/destino"
        android:textColor="@color/txt_text"
        android:textStyle="bold" />

    <AutoCompleteTextView
        android:id="@+id/rota_edt_destino"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/edt_right_margin"
        android:layout_marginStart="@dimen/edt_left_margin"
        android:layout_marginTop="@dimen/edt_top_margin"
        android:fontFamily="sans-serif-condensed"
        android:inputType="textCapCharacters"
        android:hint="@string/action_type_destination"
        android:maxLines="1"
        android:singleLine="true"
        android:textColor="@color/edt_text"
        android:textColorHint="@color/edt_text"
        android:textSize="@dimen/edt_text_size"
        android:layout_marginBottom="7dp"/>


    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/txt_left_margin"
        android:fontFamily="sans-serif-condensed"
        android:text="@string/companhia"
        android:textColor="@color/txt_text"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/rota_edt_companhia"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="7dp"
        android:layout_marginEnd="@dimen/edt_right_margin"
        android:layout_marginStart="@dimen/edt_left_margin"
        android:layout_marginTop="@dimen/edt_top_margin"
        android:fontFamily="sans-serif-condensed"
        android:inputType="none"
        android:maxLines="1"
        android:singleLine="true"
        android:textColor="@color/edt_text"
        android:textIsSelectable="true"
        android:textSize="@dimen/edt_text_size" />

</LinearLayout>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end"
    android:layout_centerInParent="true"
    android:completionThreshold="3"
    android:src="@drawable/common_google_signin_btn_icon_light_focused"
    android:background="@color/colorAccent" 
    android:id="@+id/image_view"
    android:layout_below="@+id/layout_top"/>

<LinearLayout

    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_alignParentBottom="true"

    android:background="@android:color/holo_orange_light">

    <ImageButton
        android:id="@+id/trasporte_a_pe"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:contentDescription="@string/place_autocomplete_search_hint"
        android:onClick="chamarRota"
        android:padding="@dimen/place_autocomplete_button_padding"
        android:src="@drawable/ic_transp_walk_white_48px"
        tools:src="?android:attr/actionModePasteDrawable" />

    <ImageButton
        android:id="@+id/trasporte_bike"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:contentDescription="@string/place_autocomplete_search_hint"
        android:onClick="chamarRota"
        android:padding="@dimen/place_autocomplete_button_padding"
        android:src="?attr/actionModeShareDrawable" />

    <ImageButton
        android:id="@+id/trasporte_carro"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:contentDescription="@string/place_autocomplete_search_hint"
        android:onClick="chamarRota"
        android:padding="@dimen/place_autocomplete_button_padding"
        android:src="?android:attr/actionModeCutDrawable" />


    <ImageButton
        android:id="@+id/trasporte_publico"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:contentDescription="@string/place_autocomplete_search_hint"
        android:onClick="chamarRota"
        android:padding="@dimen/place_autocomplete_button_padding"
        android:src="?android:attr/alertDialogIcon" />

</LinearLayout>

Some tips regarding the code:

  • Within RelativeLayout, views are positioned one relative to another.
  • In this case, the height of most views should be wrap_content, except for the root.
  • layout_alignParent ... does the ALIGNMENT with the parent view and does not manipulate the dimensions of the element.
  • margin and padding are good for separating views from one another. Using to position relative to the parent view, especially using specific values, can cause problems like overlapping views.
  • parent is not the previous view, but is the parent view, within which the view is.
  • 14.01.2017 / 00:24