1
I’m putting together a layout and the layout isn’t occupying the entire screen. I’ve tried it in many ways, but it’s never possible that it will, so it’s not fitting everything I need.
Problem happens when placing the scrollview, it is possible to have the whole screen, with it?
Follows 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>
Follows image of how it is:
I need you to take the whole screen, so it’s well distributed. Only vertically same.
thanks for the help!
-EDIT- XML changed, but when placing the scrollview, so that it is possible to scroll the screen with the keyboard open, it limits me to the marked image.
<?xml version="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>
@Guilhermenascimento the problem is when I put the scrollview, would it be possible to do with scrollview? Because when I put it does not go to the whole screen.
– Henrique
@Guilhermenascimento if I don’t have the scrollview, I can do it according to the answer below. I can manipulate the layout all over the screen. But when I put the scrollview, for example being "father" of the entire layout, it limits me, in this small space of the image, managed to understand?
– Henrique
@I don’t know what a viewport is. The scrollview I would like it to be possible scroll through the whole screen, when the keyboard is open, so I believe it should be inside the relativelayout, I will put the XML, "new", but still without the scrollview.
– Henrique
Try to root scrollView, like Scrollview > Relativelayout > Linearlayout and do the rest as in the answer below.
– Guilherme Nascimento
@Guilhermenascimento I tried, I cannot understand why not let move the whole screen
– Henrique
It’s true, it does so remove Relative and leaves only Scrollview > Linearlayout, see if it works, is that I am without androidstudio here, but tomorrow in the office I will test also anything ;)
– Guilherme Nascimento
@Guilhermenascimento Since scrollview can only have one "son" I added another linear layout, vertically, it really gives me a larger work area and better distribution of the screen. But even so, it is not the whole screen, but it has improved a lot! And quiet, here is no hurry haha was worth too much already!
– Henrique