RelativeLayout不会占据整个屏幕

时间:2019-10-08 19:48:50

标签: android android-linearlayout android-relativelayout

我有一个具有主布局的应用程序,其中我有几个LinearLayout,都在RelativeLayout中,并且我在LineareLayout上使用了Elevation,而且RelativeLayout似乎没有占据整个屏幕。

我已经尝试了所有可用的布局类型,但是结果总是一样的,我需要帮助。

代码只是我的结构的一个示例。

this is the result of my relative layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LayoutPrincipal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
        android:id="@+id/tolbarInitManut"
        layout="@layout/custom_toolbar"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="136dp" />

    <ScrollView
        android:id="@+id/scrollViewInitManut"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/tolbarInitManut">


        <android.support.constraint.ConstraintLayout
            android:id="@+id/initManutencao"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            tools:context=".initManutencao">

            <TextView
                android:id="@+id/txt_Cliente"
                android:layout_width="155dp"
                android:layout_height="27dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="8dp"
                android:fontFamily="@font/calibri"
                android:gravity="left|start"
                android:text="@string/cliente"
                app:autoSizeMaxTextSize="100sp"
                app:autoSizeMinTextSize="12sp"
                app:autoSizeStepGranularity="2sp"
                app:autoSizeTextType="uniform"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/Manutencao"
                tools:ignore="RtlHardcoded" />

            <TextView
                android:id="@+id/Manutencao"
                android:layout_width="0dp"
                android:layout_height="26dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="8dp"
                android:layout_marginEnd="16dp"
                android:fontFamily="@font/calibri"
                android:orientation="horizontal"
                android:text="@string/txt_manutencao"
                android:textAlignment="textEnd"
                app:autoSizeMaxTextSize="100sp"
                app:autoSizeMinTextSize="12sp"
                app:autoSizeStepGranularity="2sp"
                app:autoSizeTextType="uniform"
                app:layout_constraintEnd_toStartOf="@+id/Nmanutencao"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/Nmanutencao"
                android:layout_width="36dp"
                android:layout_height="0dp"
                android:layout_marginEnd="16dp"
                android:fontFamily="@font/calibri"
                android:text="@string/_10"
                android:textAlignment="center"
                android:textStyle="bold"
                app:autoSizeMaxTextSize="100sp"
                app:autoSizeMinTextSize="12sp"
                app:autoSizeStepGranularity="2sp"
                app:autoSizeTextType="uniform"
                app:layout_constraintBottom_toBottomOf="@+id/Manutencao"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/Manutencao"
                app:layout_constraintTop_toTopOf="@+id/Manutencao" />

            <LinearLayout
                android:id="@+id/passo1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="16dp"
                android:layout_marginTop="8dp"
                android:layout_marginEnd="16dp"
                android:background="@drawable/background_shape"
                android:elevation="1.5dp"
                android:orientation="vertical"
                android:paddingTop="16dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.4"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/txt_Cliente">

                <TextView
                    android:id="@+id/PreTratamento"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginStart="16dp"
                    android:layout_marginEnd="16dp"
                    android:fontFamily="@font/calibri"
                    android:gravity="center"
                    android:padding="0dp"
                    android:text="@string/PreTratamento"
                    android:textSize="30sp"
                    android:textStyle="bold"
                    app:layout_constraintBottom_toTopOf="@+id/back_header_alert" />

                <View
                    android:id="@+id/view1"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginEnd="16dp"
                    android:layout_marginBottom="8dp"
                    android:background="@android:color/darker_gray" />

                <LinearLayout
                    android:id="@+id/passo1_1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:paddingBottom="16dp">

                    <TextView
                        android:id="@+id/CaixaDeGordura"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginEnd="16dp"
                        android:fontFamily="@font/calibri"
                        android:text="@string/caixa_de_gordura"
                        android:textSize="30sp" />

                    <LinearLayout
                        android:id="@+id/passo1_1_1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginEnd="16dp"
                        android:layout_marginBottom="8dp"
                        android:orientation="vertical">

                        <Spinner
                            android:id="@+id/spn_ex_cx_gordura"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:background="@drawable/spinner_border"
                            android:popupBackground="@drawable/background_shape"
                            android:spinnerMode="dropdown" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/passo1_1_2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginEnd="16dp"
                        android:orientation="vertical"
                        android:visibility="gone">

                        <Spinner
                            android:id="@+id/spn_projeto_sub"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:background="@drawable/spinner_border"
                            android:popupBackground="@drawable/background_shape" />

                        <EditText
                            android:id="@+id/txt_obs_cx_gordura"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:autofillHints=""
                            android:ems="10"
                            android:fontFamily="@font/calibri"
                            android:hint="@string/txt_obs_cx_gordura"
                            android:inputType="textPersonName"
                            tools:targetApi="o" />

                        <LinearLayout
                            android:id="@+id/btn_im_cx_gord"
                            style="?android:attr/buttonBarButtonStyle"
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1"
                            android:background="@drawable/backgroud_button"
                            android:onClick="openAlertDialog"
                            android:orientation="horizontal"
                            tools:ignore="MissingConstraints">

                            <ImageView
                                style="?android:attr/buttonBarButtonStyle"
                                android:layout_width="34dp"
                                android:layout_height="29dp"
                                android:background="#0000"
                                android:clickable="false"
                                android:src="@drawable/ic_photo_camera_black_24dp" />

                            <TextView
                                style="?android:attr/buttonBarButtonStyle"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:background="#0000"
                                android:clickable="false"
                                android:text="@string/camera"
                                android:textColor="@color/WhiteColor" />
                        </LinearLayout>
                    </LinearLayout>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/passo1_2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:paddingBottom="16dp">

                    <TextView
                        android:id="@+id/gradeamento"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginEnd="16dp"
                        android:fontFamily="@font/calibri"
                        android:text="@string/gradeamento"
                        android:textSize="30sp" />

                    <LinearLayout
                        android:id="@+id/passo1_2_1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginEnd="16dp"
                        android:layout_marginBottom="8dp"
                        android:orientation="vertical">

                        <Spinner
                            android:id="@+id/spn_ex_grad"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:background="@drawable/spinner_border"
                            android:fontFamily="@font/calibri" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/passo1_2_2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginEnd="16dp"
                        android:orientation="vertical"
                        android:visibility="gone">

                        <Spinner
                            android:id="@+id/spn_mod_grad"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:background="@drawable/spinner_border"
                            android:fontFamily="@font/calibri" />

                        <Spinner
                            android:id="@+id/spn_st_grad"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:background="@drawable/spinner_border"
                            android:fontFamily="@font/calibri" />

                        <Spinner
                            android:id="@+id/spn_pres_gordura_grad"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:background="@drawable/spinner_border"
                            android:fontFamily="@font/calibri" />

                        <Spinner
                            android:id="@+id/spn_res_pros_prod_grad"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:background="@drawable/spinner_border"
                            android:fontFamily="@font/calibri" />

                        <EditText
                            android:id="@+id/txt_obs_cx_grad"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:autofillHints=""
                            android:ems="10"
                            android:fontFamily="@font/calibri"
                            android:hint="@string/txt_obs_cx_gordura"
                            android:inputType="textPersonName"
                            tools:targetApi="o" />

                        <LinearLayout
                            android:id="@+id/btn_im_grad"
                            style="?android:attr/buttonBarButtonStyle"
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1"
                            android:background="@drawable/backgroud_button"
                            android:onClick="openAlertDialog"
                            android:orientation="horizontal"
                            tools:ignore="MissingConstraints">

                            <ImageView
                                style="?android:attr/buttonBarButtonStyle"
                                android:layout_width="34dp"
                                android:layout_height="29dp"
                                android:background="#0000"
                                android:clickable="false"
                                android:src="@drawable/ic_photo_camera_black_24dp" />

                            <TextView
                                style="?android:attr/buttonBarButtonStyle"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:background="#0000"
                                android:clickable="false"
                                android:text="@string/camera"
                                android:textColor="@color/WhiteColor" />
                        </LinearLayout>
                    </LinearLayout>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/passo1_3"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:paddingBottom="16dp">

                    <TextView
                        android:id="@+id/cesto"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginEnd="16dp"
                        android:fontFamily="@font/calibri"
                        android:text="Cesto"
                        android:textSize="30sp" />

                    <LinearLayout
                        android:id="@+id/passo1_3_1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginEnd="16dp"
                        android:layout_marginBottom="8dp"
                        android:orientation="vertical">

                        <Spinner
                            android:id="@+id/spn_ex_cesto"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:background="@drawable/spinner_border"
                            android:fontFamily="@font/calibri" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/passo1_3_2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginEnd="16dp"
                        android:orientation="vertical"
                        android:visibility="gone">

                        <Spinner
                            android:id="@+id/spn_mod_cesto"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:background="@drawable/spinner_border"
                            android:fontFamily="@font/calibri" />

                        <Spinner
                            android:id="@+id/spn_st_cest"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:background="@drawable/spinner_border"
                            android:fontFamily="@font/calibri" />

                        <Spinner
                            android:id="@+id/spn_pres_gordura_cest"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:background="@drawable/spinner_border"
                            android:fontFamily="@font/calibri" />

                        <Spinner
                            android:id="@+id/spn_res_pros_prod_cest"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:background="@drawable/spinner_border"
                            android:fontFamily="@font/calibri" />

                        <EditText
                            android:id="@+id/txt_obs_cx_cest"
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:layout_marginBottom="8dp"
                            android:autofillHints=""
                            android:ems="10"
                            android:fontFamily="@font/calibri"
                            android:hint="@string/txt_obs_cx_cesto"
                            android:inputType="textPersonName" />

                        <LinearLayout
                            android:id="@+id/btn_im_cest"
                            style="?android:attr/buttonBarButtonStyle"
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1"
                            android:background="@drawable/backgroud_button"
                            android:onClick="openAlertDialog"
                            android:orientation="horizontal"
                            tools:ignore="MissingConstraints">

                            <ImageView
                                style="?android:attr/buttonBarButtonStyle"
                                android:layout_width="34dp"
                                android:layout_height="29dp"
                                android:background="#0000"
                                android:clickable="false"
                                android:src="@drawable/ic_photo_camera_black_24dp" />

                            <TextView
                                style="?android:attr/buttonBarButtonStyle"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:background="#0000"
                                android:clickable="false"
                                android:text="@string/camera"
                                android:textColor="@color/WhiteColor" />
                        </LinearLayout>
                    </LinearLayout>

                </LinearLayout>
            </LinearLayout>
            </android.support.constraint.ConstraintLayout>

            <TextView
                android:id="@+id/txt_passo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="TextView"
                app:layout_constraintBottom_toBottomOf="@+id/txt_Cliente"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@+id/txt_Cliente"
                app:layout_constraintTop_toTopOf="@+id/txt_Cliente" />

        </android.support.constraint.ConstraintLayout>
    </ScrollView>

1 个答案:

答案 0 :(得分:0)

在滚动视图中,您需要添加android:fillViewPort =“ true”

要使滚动视图中的内容适合整个屏幕。