ScrollView在android studio中不起作用,期望的输出没有出现

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ScrollView在android studio中不起作用,期望的输出没有出现相关的知识,希望对你有一定的参考价值。

以下代码的输出未作为要求的输出出现。滚动视图未涵盖全屏。我正在尝试在滚动视图内使用约束布局。请帮助.......约束布局的内容变得重叠,并且约束布局无法覆盖整个屏幕。...

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
    xmlns:fancy="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <com.libizo.CustomEditText
            android:id="@+id/Email"
            android:layout_width="285dp"
            android:layout_height="69dp"
            android:ems="10"
            android:hint="Email"
            android:inputType="textPersonName"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.873"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.111"
            app:libIZO_clearIconTint="#8f1f15"
            app:libIZO_setBorderColor="#8f1f15"
            app:libIZO_setBorderView="true"
            app:libIZO_setClearIconVisible="true"
            app:libIZO_setCornerRadius="4dp"
            app:libIZO_setStrokeWidth="2dp" />

        <ImageView
            android:id="@+id/icon_mail"
            android:layout_width="75dp"
            android:layout_height="66dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.047"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.115"
            app:srcCompat="@drawable/ic_email"
            tools:ignore="ContentDescription,UnusedAttribute,VectorDrawableCompat" />

        <mehdi.sakout.fancybuttons.FancyButton
            android:id="@+id/Login"
            android:layout_width="204dp"
            android:layout_height="75dp"

            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.497"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.417"
            fancy:fb_borderColor="#FFFFFF"
            fancy:fb_borderWidth="1dp"
            fancy:fb_defaultColor="#7ab800"
            fancy:fb_focusColor="#9bd823"
            fancy:fb_iconPosition="left"
            fancy:fb_radius="30dp"
            fancy:fb_text="Login / Register"
            fancy:fb_textColor="#FFFFFF"
            fancy:fb_textSize="25dp" />

        <ImageView
            android:id="@+id/icon_lock"
            android:layout_width="80dp"
            android:layout_height="68dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.048"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.268"
            app:srcCompat="@drawable/ic_lock"
            tools:ignore="ContentDescription,UnusedAttribute,VectorDrawableCompat" />

        <com.libizo.CustomEditText
            android:id="@+id/Password"
            android:layout_width="285dp"
            android:layout_height="69dp"
            android:ems="10"
            android:hint="Password"
            android:inputType="textPassword"
            android:textSize="20sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.873"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.268"
            app:libIZO_clearIconTint="#8f1f15"
            app:libIZO_setBorderColor="#8f1f15"
            app:libIZO_setBorderView="true"
            app:libIZO_setClearIconVisible="true"
            app:libIZO_setCornerRadius="4dp"
            app:libIZO_setStrokeWidth="2dp" />

        <TextView
            android:id="@+id/Forgot_Password"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Forgot Password ?"
            android:textSize="30dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.496"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.527" />

        <ProgressBar
            android:id="@+id/progressBar"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:visibility="gone"/>

        <Button
            android:id="@+id/Google"
            android:layout_width="168dp"
            android:layout_height="145dp"
            android:background="@drawable/ic_google"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.884"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.725" />

        <Button
            android:id="@+id/Phone"
            android:layout_width="168dp"
            android:layout_height="145dp"
            android:background="@drawable/ic_phone"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.148"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.725" />

        <Button
            android:id="@+id/Facebook"
            android:layout_width="208dp"
            android:layout_height="156dp"
            android:background="@drawable/ic_facebook"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.541"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.991" />
    </androidx.constraintlayout.widget.ConstraintLayout>


</ScrollView>

The Output for the following code is shown here

答案

尝试像这样更改您对小部件的约束:

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

    >
    <com.libizo.CustomEditText
        android:id="@+id/Email"
        android:layout_width="285dp"
        android:layout_height="69dp"
        android:ems="10"
        android:hint="Email"
        android:inputType="textPersonName"
        app:layout_constraintBottom_toTopOf="@+id/icon_lock"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.873"
        app:layout_constraintStart_toStartOf="@+id/icon_mail"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.111"
        app:libIZO_clearIconTint="#8f1f15"
        app:libIZO_setBorderColor="#8f1f15"
        app:libIZO_setBorderView="true"
        app:libIZO_setClearIconVisible="true"
        app:libIZO_setCornerRadius="4dp"
        app:libIZO_setStrokeWidth="2dp"

        />

    <ImageView
        android:id="@+id/icon_mail"
        android:layout_width="75dp"
        android:layout_height="66dp"
        app:layout_constraintBottom_toTopOf="@+id/icon_lock"
        app:layout_constraintEnd_toEndOf="@+id/Email"
        app:layout_constraintHorizontal_bias="0.047"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.115"
        app:srcCompat="@drawable/ic_email"
        tools:ignore="ContentDescription,UnusedAttribute,VectorDrawableCompat" />


    <com.libizo.CustomEditText
        android:id="@+id/Password"
        android:layout_width="285dp"
        android:layout_height="69dp"
        android:ems="10"
        android:hint="Password"
        android:inputType="textPassword"
        android:textSize="20sp"
        app:layout_constraintBottom_toTopOf="@+id/Login"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.873"
        app:layout_constraintStart_toEndOf="@+id/icon_lock"
        app:layout_constraintTop_toBottomOf="@+id/icon_mail"
        app:layout_constraintVertical_bias="0.268"
        app:libIZO_clearIconTint="#8f1f15"
        app:libIZO_setBorderColor="#8f1f15"
        app:libIZO_setBorderView="true"
        app:libIZO_setClearIconVisible="true"
        app:libIZO_setCornerRadius="4dp"
        app:libIZO_setStrokeWidth="2dp"
     />

    <ImageView
        android:id="@+id/icon_lock"
        android:layout_width="80dp"
        android:layout_height="68dp"
        app:layout_constraintBottom_toTopOf="@id/Login"
        app:layout_constraintEnd_toStartOf="@id/Password"
        app:layout_constraintHorizontal_bias="0.048"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/icon_mail"
        app:layout_constraintVertical_bias="0.268"
        app:srcCompat="@drawable/ic_lock"
        tools:ignore="ContentDescription,UnusedAttribute,VectorDrawableCompat" />



    <mehdi.sakout.fancybuttons.FancyButton
        android:id="@+id/Login"
        android:layout_width="204dp"
        android:layout_height="75dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.497"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/Password"
        app:layout_constraintVertical_bias="0.417"
        />

    <TextView
        android:id="@+id/Forgot_Password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Forgot Password ?"
        android:textSize="30dp"
        app:layout_constraintBottom_toTopOf="@+id/progressBar"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.496"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/Login"
        app:layout_constraintVertical_bias="0.527" />

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@id/Google"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/Forgot_Password"
        android:visibility="invisible"/>

    <Button
        android:id="@+id/Google"
        android:layout_width="168dp"
        android:layout_height="145dp"
        android:background="@drawable/ic_google"
        app:layout_constraintBottom_toTopOf="@id/Facebook"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.884"
        app:layout_constraintStart_toEndOf="@id/Phone"
        app:layout_constraintTop_toBottomOf="progressBar"
        app:layout_constraintVertical_bias="0.725" />

    <Button
        android:id="@+id/Phone"
        android:layout_width="168dp"
        android:layout_height="145dp"
        android:background="@drawable/ic_phone"
        app:layout_constraintBottom_toTopOf="@id/Facebook"
        app:layout_constraintEnd_toStartOf="@id/Google"
        app:layout_constraintHorizontal_bias="0.148"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/progressBar"
        app:layout_constraintVertical_bias="0.725" />

    <Button
        android:id="@+id/Facebook"
        android:layout_width="208dp"
        android:layout_height="156dp"
         android:background="@drawable/ic_facebook"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintHorizontal_bias="0.541"
        app:layout_constraintTop_toBottomOf="@+id/Phone"
        app:layout_constraintVertical_bias="0.991" />
</androidx.constraintlayout.widget.ConstraintLayout>

另一答案

您设置了错误的Constraint来查看。尝试如下。它会给您一些想法,并根据您的需要进行更改。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
    xmlns:fancy="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <ImageView
            android:id="@+id/icon_mail"
            android:layout_width="75dp"
            android:layout_height="66dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/ic_email"
            tools:ignore="ContentDescription,UnusedAttribute,VectorDrawableCompat" />

        <com.libizo.CustomEditText
            android:id="@+id/Email"
            android:layout_width="285dp"
            android:layout_height="69dp"
            android:ems="10"
            android:hint="Email"
            android:inputType="textPersonName"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:libIZO_clearIconTint="#8f1f15"
            app:libIZO_setBorderColor="#8f1f15"
            app:libIZO_setBorderView="true"
            app:libIZO_setClearIconVisible="true"
            app:libIZO_setCornerRadius="4dp"
            app:libIZO_setStrokeWidth="2dp" />

        <ImageView
            android:id="@+id/icon_lock"
            android:layout_width="80dp"
            android:layout_height="68dp"
            a

以上是关于ScrollView在android studio中不起作用,期望的输出没有出现的主要内容,如果未能解决你的问题,请参考以下文章

ANDROID STUDIO:如何修复我的 ScrollView?

滚动视图android studio bouncable

Android studio 制作一张长图,可上下滑动

cocos Studio中ScrollView选择裁切后显示白底的问题

Android Studio学习02:App首页布局

如何在ScrollView嵌套另一个ScrollView