无法将文本视图或任何对象放置在屏幕的一半以下

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </com.google.android.material.appbar.AppBarLayout>

    <include layout="@layout/content_main" />


<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/gender"
            android:layout_width="96dp"
            android:layout_height="49dp"
            android:layout_gravity="center"
            android:paddingTop="30dp"
            android:text="GENDER"
            android:textAlignment="center"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@android:color/holo_red_dark"
            android:textStyle="bold|italic"
            android:typeface="serif"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.295"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.102" />

        <TextView
            android:id="@+id/tv4"
            android:layout_width="96dp"
            android:layout_height="49dp"
            android:layout_gravity="center"
            android:layout_marginTop="116dp"
            android:paddingTop="30dp"
            android:text="HEIGHT"
            android:textAlignment="center"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@android:color/holo_red_dark"
            android:textStyle="bold|italic"
            android:typeface="serif"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.295"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />


        <org.angmarch.views.NiceSpinner
            android:id="@+id/weight_spinner"
            android:layout_width="148dp"
            android:layout_height="52dp"
            android:layout_marginBottom="12dp"
            app:layout_constraintBottom_toTopOf="@+id/weight_et"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.222"
            app:layout_constraintStart_toEndOf="@+id/tv3" />

        <EditText
            android:id="@+id/weight_et"
            android:layout_width="139dp"
            android:layout_height="38dp"
            android:layout_gravity="center"
            android:layout_marginTop="28dp"
            android:ems="10"
            android:fadingEdgeLength="10dp"
            android:hint="Enter Weight"
            android:inputType="numberDecimal"
            android:textAlignment="center"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.283"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/tv3" />

        <TextView
            android:id="@+id/tv3"
            android:layout_width="107dp"
            android:layout_height="55dp"
            android:layout_gravity="center"
            android:paddingTop="30dp"
            android:text="WEIGHT"
            android:textAlignment="center"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@android:color/holo_red_dark"
            android:textStyle="bold|italic"
            android:typeface="serif"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.305"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/height_et" />

        <Button
            android:id="@+id/ib1"
            android:layout_width="158dp"
            android:layout_height="51dp"
            android:layout_gravity="center"
            android:layout_marginTop="28dp"
            android:background="@android:color/holo_blue_dark"
            android:capitalize="words"
            android:fadingEdge="vertical"
            android:longClickable="true"
            android:text="Calculate"
            android:textColor="@android:color/holo_green_light"
            android:textStyle="bold|italic"
            android:visibility="gone"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.498"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/weight_et" />

        <org.angmarch.views.NiceSpinner
            android:id="@+id/height_spinner"
            android:layout_width="148dp"
            android:layout_height="54dp"
            android:layout_marginBottom="16dp"
            app:layout_constraintBottom_toTopOf="@+id/height_et"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.148"
            app:layout_constraintStart_toEndOf="@+id/tv4" />

        <EditText
            android:id="@+id/height_et"
            android:layout_width="137dp"
            android:layout_height="43dp"
            android:layout_gravity="center"
            android:layout_marginTop="32dp"
            android:ems="10"
            android:hint="Enter Height"
            android:inputType="numberDecimal"
            android:textAlignment="center"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.281"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/tv4"/>

        <TextView
            android:id="@+id/result_tv"
            android:layout_width="200dp"
            android:layout_height="66dp"
            android:layout_gravity="center"
            android:paddingTop="20dp"
            android:text=""
            android:textAlignment="center"
            android:textColor="@android:color/holo_orange_dark"
            android:textSize="20dp"
            android:textStyle="bold"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.027"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/ib1"
            app:layout_constraintVertical_bias="1.0" />

        <EditText
            android:id="@+id/ft_in_et"
            android:layout_width="158dp"
            android:layout_height="44dp"
            android:layout_marginBottom="20dp"
            android:ems="10"
            android:hint=""
            android:inputType="numberDecimal"
            android:textAlignment="center"
            android:visibility="gone"
            android:enabled="false"
            app:layout_constraintBottom_toTopOf="@+id/weight_spinner"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.27"
            app:layout_constraintStart_toEndOf="@+id/height_et" />

        <EditText
            android:id="@+id/st_lb_et"
            android:layout_width="149dp"
            android:layout_height="41dp"
            android:ems="10"
            android:hint="lb"
            android:inputType="numberDecimal"
            android:textAlignment="center"
            android:visibility="gone"
            app:layout_constraintBottom_toTopOf="@+id/ib1"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.076"
            app:layout_constraintStart_toEndOf="@+id/weight_et" />

        <TextView
            android:id="@+id/ideal_weight"
            android:layout_width="171dp"
            android:layout_height="64dp"
            android:gravity="center"
            android:text=""
            android:textAlignment="center"
            android:textSize="20dp"
            android:textStyle="bold"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.982"
            app:layout_constraintStart_toStartOf="@+id/result_tv" />

        <org.angmarch.views.NiceSpinner
            android:id="@+id/gender_spinner"
            android:layout_width="187dp"
            android:layout_height="50dp"
            app:layout_constraintBottom_toTopOf="@+id/tv4"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.982"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="1.0" />


        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            app:adSize="BANNER"
            app:adUnitId="ca-app-pub-3940256099942544/6300978111"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"></com.google.android.gms.ads.AdView>


    </androidx.constraintlayout.widget.ConstraintLayout>



</ScrollView>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:backgroundTint="#009688"
        app:srcCompat="@drawable/ic_reset" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>


正如您在图像中看到的,屏幕的一半是不可编辑的
正如您在图像中看到的,屏幕的一半是不可编辑的
正如您在图像中看到的,屏幕的一半是不可编辑的
[这里是布局图]
https://i.stack.imgur.com/OKygh.jpg

最佳答案

问题出在您的ConstraintLayout内部。您使用了错误的约束。

修复了一些:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary" />

    </com.google.android.material.appbar.AppBarLayout>


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/gender"
                android:layout_width="96dp"
                android:layout_height="49dp"
                android:layout_gravity="center"
                android:paddingTop="30dp"
                android:text="GENDER"
                android:textAlignment="center"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@android:color/holo_red_dark"
                android:textStyle="bold|italic"
                android:typeface="serif"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.295"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.102" />

            <TextView
                android:id="@+id/tv4"
                android:layout_width="96dp"
                android:layout_height="49dp"
                android:layout_gravity="center"
                android:layout_marginTop="116dp"
                android:paddingTop="30dp"
                android:text="HEIGHT"
                android:textAlignment="center"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@android:color/holo_red_dark"
                android:textStyle="bold|italic"
                android:typeface="serif"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.295"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />


            <org.angmarch.views.NiceSpinner
                android:id="@+id/weight_spinner"
                android:layout_width="148dp"
                android:layout_height="52dp"
                android:layout_marginBottom="12dp"
                app:layout_constraintBottom_toTopOf="@+id/weight_et"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.222"
                app:layout_constraintStart_toEndOf="@+id/tv3" />

            <EditText
                android:id="@+id/weight_et"
                android:layout_width="139dp"
                android:layout_height="38dp"
                android:layout_gravity="center"
                android:layout_marginTop="28dp"
                android:ems="10"
                android:fadingEdgeLength="10dp"
                android:hint="Enter Weight"
                android:inputType="numberDecimal"
                android:textAlignment="center"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.283"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/tv3" />

            <TextView
                android:id="@+id/tv3"
                android:layout_width="107dp"
                android:layout_height="55dp"
                android:layout_gravity="center"
                android:paddingTop="30dp"
                android:text="WEIGHT"
                android:textAlignment="center"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@android:color/holo_red_dark"
                android:textStyle="bold|italic"
                android:typeface="serif"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.305"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/height_et" />

            <Button
                android:id="@+id/ib1"
                android:layout_width="158dp"
                android:layout_height="51dp"
                android:layout_gravity="center"
                android:layout_marginTop="28dp"
                android:background="@android:color/holo_blue_dark"
                android:capitalize="words"
                android:fadingEdge="vertical"
                android:longClickable="true"
                android:text="Calculate"
                android:textColor="@android:color/holo_green_light"
                android:textStyle="bold|italic"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.498"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/weight_et" />

            <org.angmarch.views.NiceSpinner
                android:id="@+id/height_spinner"
                android:layout_width="148dp"
                android:layout_height="54dp"
                android:layout_marginBottom="16dp"
                app:layout_constraintBottom_toTopOf="@+id/height_et"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.148"
                app:layout_constraintStart_toEndOf="@+id/tv4" />

            <EditText
                android:id="@+id/height_et"
                android:layout_width="137dp"
                android:layout_height="43dp"
                android:layout_gravity="center"
                android:layout_marginTop="32dp"
                android:ems="10"
                android:hint="Enter Height"
                android:inputType="numberDecimal"
                android:textAlignment="center"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.281"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/tv4"/>

            <TextView
                android:id="@+id/result_tv"
                android:layout_width="200dp"
                android:layout_height="66dp"
                android:layout_gravity="center"
                android:paddingTop="20dp"
                android:text="Result"
                android:textAlignment="center"
                android:textColor="@android:color/holo_orange_dark"
                android:textSize="20dp"
                android:textStyle="bold"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.027"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/ib1"
                app:layout_constraintVertical_bias="1.0" />

            <EditText
                android:id="@+id/ft_in_et"
                android:layout_width="158dp"
                android:layout_height="44dp"
                android:layout_marginBottom="20dp"
                android:ems="10"
                android:hint="lb"
                android:inputType="numberDecimal"
                android:textAlignment="center"
                android:enabled="false"
                app:layout_constraintBottom_toTopOf="@+id/weight_spinner"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.27"
                app:layout_constraintStart_toEndOf="@+id/height_et" />

            <EditText
                android:id="@+id/st_lb_et"
                android:layout_width="149dp"
                android:layout_height="41dp"
                android:ems="10"
                android:hint="lb"
                android:inputType="numberDecimal"
                android:textAlignment="center"
                app:layout_constraintTop_toBottomOf="@+id/weight_spinner"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.076"
                app:layout_constraintStart_toEndOf="@+id/weight_et" />

            <TextView
                android:id="@+id/ideal_weight"
                android:layout_width="171dp"
                android:layout_height="64dp"
                android:gravity="center"
                android:text=""
                android:textAlignment="center"
                android:textSize="20dp"
                android:textStyle="bold"
                app:layout_constraintBottom_toTopOf="@+id/adView"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.982"
                app:layout_constraintStart_toStartOf="@+id/result_tv" />

            <org.angmarch.views.NiceSpinner
                android:id="@+id/gender_spinner"
                android:layout_width="187dp"
                android:layout_height="50dp"
                app:layout_constraintBottom_toTopOf="@+id/tv4"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.982"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="1.0" />


            <com.google.android.gms.ads.AdView
                android:id="@+id/adView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                app:adSize="BANNER"
                app:adUnitId="ca-app-pub-3940256099942544/6300978111"
                app:layout_constraintTop_toBottomOf="@+id/result_tv"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent" />


        </androidx.constraintlayout.widget.ConstraintLayout>



    </ScrollView>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="16dp"
        app:backgroundTint="#009688"
        app:srcCompat="@android:drawable/ic_menu_search" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>


输出:
java - TextView没有放在屏幕的一半以下-LMLPHP

10-04 13:06