2017-06-20 192 views
0

這是應用程序的一部分,用戶在樹中查找各種複選框,然後顯示擬合樹列表。Scrollview不會滾動

我在屏幕頂部有一個edittext字段和按鈕的活動,然後在它們下面,它們都是一個帶有單個文本視圖(顯然是在線性佈局內)的滾動視圖。基於用戶在之前的活動中檢查的各種複選框,textview的大小會有所不同。

問題是,當textview變成一個很長的列表:我不能向下滾動屏幕查看整個列表。我只能看到列表頂部的內容。

這裏是我的活動XML:

<EditText 
    android:id="@+id/et_item" 
    android:layout_width="0dp" 
    android:layout_height="0dp" 
    android:layout_marginEnd="9dp" 
    android:layout_marginLeft="7dp" 
    android:layout_marginRight="9dp" 
    android:layout_marginStart="7dp" 
    android:ems="10" 
    android:hint="Item..." 
    android:inputType="textPersonName" 
    app:layout_constraintBottom_toBottomOf="@+id/scrollView2" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toLeftOf="@+id/button2" 
    app:layout_constraintTop_toTopOf="parent" 
    tools:layout_constraintBottom_creator="1" 
    tools:layout_constraintLeft_creator="1" 
    tools:layout_constraintRight_creator="1" 
    tools:layout_constraintTop_creator="1" /> 

<Button 
    android:id="@+id/button2" 
    android:layout_width="88dp" 
    android:layout_height="48dp" 
    android:text="Find" 
    tools:layout_constraintTop_creator="1" 
    android:layout_marginStart="301dp" 
    tools:layout_constraintLeft_creator="1" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    android:layout_marginLeft="301dp" 
    android:onClick="find" /> 

<TextView 
    android:id="@+id/tv1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="16dp" 
    android:layout_marginStart="16dp" 
    android:layout_marginTop="170dp" 
    android:textAppearance="@style/TextAppearance.AppCompat.Title" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    tools:layout_constraintLeft_creator="1" 
    tools:layout_constraintTop_creator="1" /> 

<ScrollView 
    android:layout_width="0dp" 
    android:layout_height="0dp" 
    android:id="@+id/scrollView2" 
    app:layout_constraintRight_toLeftOf="@+id/linearLayout" 
    tools:layout_constraintTop_creator="1" 
    tools:layout_constraintRight_creator="1" 
    tools:layout_constraintBottom_creator="1" 
    app:layout_constraintBottom_toTopOf="@+id/linearLayout" 
    tools:layout_constraintLeft_creator="1" 
    app:layout_constraintLeft_toLeftOf="@+id/linearLayout" 
    app:layout_constraintTop_toTopOf="@+id/linearLayout"> 

</ScrollView> 

<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:layout_marginStart="8dp" 
    android:id="@+id/linearLayout" 
    tools:layout_constraintTop_creator="1" 
    android:layout_marginTop="43dp" 
    tools:layout_constraintLeft_creator="1" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    android:layout_marginLeft="8dp"> 

    <TextView 
     android:id="@+id/tv_results" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginStart="16dp" 
     android:layout_marginTop="11dp" 
     android:text="Results..." 
     android:textAppearance="@style/TextAppearance.AppCompat.Title" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     tools:layout_constraintLeft_creator="1" 
     tools:layout_constraintTop_creator="1" /> 

</LinearLayout> 

爲什麼不會滾動工作?

+3

滾動型似乎是空的? –

+0

下面移動> – thorin86

回答

0

這應該修復它:

<EditText 
    android:id="@+id/et_item" 
    android:layout_width="0dp" 
    android:layout_height="0dp" 
    android:layout_marginEnd="9dp" 
    android:layout_marginLeft="7dp" 
    android:layout_marginRight="9dp" 
    android:layout_marginStart="7dp" 
    android:ems="10" 
    android:hint="Item..." 
    android:inputType="textPersonName" 
    app:layout_constraintBottom_toBottomOf="@+id/scrollView2" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toLeftOf="@+id/button2" 
    app:layout_constraintTop_toTopOf="parent" 
    tools:layout_constraintBottom_creator="1" 
    tools:layout_constraintLeft_creator="1" 
    tools:layout_constraintRight_creator="1" 
    tools:layout_constraintTop_creator="1" /> 

<Button 
    android:id="@+id/button2" 
    android:layout_width="88dp" 
    android:layout_height="48dp" 
    android:text="Find" 
    tools:layout_constraintTop_creator="1" 
    android:layout_marginStart="301dp" 
    tools:layout_constraintLeft_creator="1" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    android:layout_marginLeft="301dp" 
    android:onClick="find" /> 

<TextView 
    android:id="@+id/tv1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="16dp" 
    android:layout_marginStart="16dp" 
    android:layout_marginTop="170dp" 
    android:textAppearance="@style/TextAppearance.AppCompat.Title" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    tools:layout_constraintLeft_creator="1" 
    tools:layout_constraintTop_creator="1" /> 

<ScrollView 
    android:layout_width="0dp" 
    android:layout_height="0dp" 
    android:id="@+id/scrollView2" 
    app:layout_constraintRight_toLeftOf="@+id/linearLayout" 
    tools:layout_constraintTop_creator="1" 
    tools:layout_constraintRight_creator="1" 
    tools:layout_constraintBottom_creator="1" 
    app:layout_constraintBottom_toTopOf="@+id/linearLayout" 
    tools:layout_constraintLeft_creator="1" 
    app:layout_constraintLeft_toLeftOf="@+id/linearLayout" 
    app:layout_constraintTop_toTopOf="@+id/linearLayout"> 


<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:layout_marginStart="8dp" 
    android:id="@+id/linearLayout" 
    tools:layout_constraintTop_creator="1" 
    android:layout_marginTop="43dp" 
    tools:layout_constraintLeft_creator="1" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    android:layout_marginLeft="8dp"> 

    <TextView 
     android:id="@+id/tv_results" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginStart="16dp" 
     android:layout_marginTop="11dp" 
     android:text="Results..." 
     android:textAppearance="@style/TextAppearance.AppCompat.Title" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     tools:layout_constraintLeft_creator="1" 
     tools:layout_constraintTop_creator="1" /> 

</LinearLayout> 
</ScrollView>