滚动视图不适用于约束布局

Scroll view doesn't work with constraint layout

滚动视图不适用于约束布局,所有内容都包含在我的 phone 屏幕中。我应该使用 scrollview 作为父布局吗?我的 ScrollView 布局的宽度应该是多少,我对 wrap_content 和 match_parent 感到困惑...................... ..................................................... ………… This is what i am getting

    <?xml version="1.0" encoding="utf-8"?>
 <android.support.constraint.ConstraintLayout 
    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"
    android:background="#1a1a22"
    tools:context="com.example.mrfrag.fullchargealarm.Settings">

   <ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/scrollView6" android:fillViewport="true"
      android:layout_marginTop="8dp"
      app:layout_constraintTop_toTopOf="parent"
      android:layout_marginEnd="8dp"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
       android:layout_marginStart="8dp"
      app:layout_constraintBottom_toBottomOf="parent"
      android:layout_marginBottom="8dp"
      android:scrollbars = "vertical"
      android:scrollbarStyle="insideInset"
      app:layout_constraintHorizontal_bias="0.0"
      app:layout_constraintVertical_bias="0.0">
     <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FIRE1" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
            android:id="@+id/textVie2321"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
            android:id="@+id/textVie23"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
            android:id="@+id/textVie45"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
            android:id="@+id/tesadasdxtVie3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
            android:id="@+id/teasasdxtVie3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
            android:id="@+id/texasastVie3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
        android:id="@+id/textVsase3"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:textColor="#ffffff"
        android:text="FFIRE" />

        <TextView
            android:id="@+id/textasdasdVsase3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
            android:id="@+id/tasdasdextVsase3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
            android:id="@+id/texastVsase3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
            android:id="@+id/texVsase3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />
        <TextView
            android:id="@+id/tetVsase3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:text="FFIRE" />

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

要使其正常工作,请将 ScrollView 设置为父视图,宽度和高度为 match_parent(以便它填满屏幕)。然后将下一个布局放入其中,宽度为 match_parent(因此它是父级的宽度)和高度为 wrap_content(因此它可以高于父级高度并滚动以显示内容).

wrap_content 是做什么的?它让视图根据需要显示其内容的高度。如果它比父级高,则 ScrollView 允许您上下滚动以查看内容。

例如:

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

    <!-- this could be a constraint layout instead if you want -->
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!-- STUFF -->

    </LinearLayout>
</ScrollView>

在你的情况下,父 ConstraintLayout 不是必需的,因为只有一个子视图并且它填充了父视图,但是如果你想保持现有的层次结构,只需立即更改 LinearLayout ScrollViewwrap_content

的高度