问题
Spinner's "skeleton" shown behind another layout while scrolling up. When I scroll up Spinner's arrow and underline shown. I want it to hide it like it going to the behind of another layout.
before scrolling
after scrolling
I have a two ConstraintLayout second one for ScrollView.
Here is part of my XML.
<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:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="159dp">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="7dp"
android:text="Cummulative GPA: 0.00"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"/>
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3"
app:layout_constraintVertical_bias="0.0">
<TextView
android:id="@+id/fenn1"
style="@style/InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fenn 1"
app:layout_constraintBottom_toTopOf="@+id/spinner"
app:layout_constraintLeft_toLeftOf="@+id/spinner"/>
<Spinner
android:id="@+id/spinner"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="8dp"
android:layout_marginTop="55dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fenn1"
/>
<TextView
android:id="@+id/label1"
style="@style/InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fenn 2"
app:layout_constraintBottom_toTopOf="@+id/spinner3"
app:layout_constraintLeft_toLeftOf="@+id/spinner3"/>
<Spinner
android:id="@+id/spinner3"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="43dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner"/>
<TextView
android:id="@+id/label2"
style="@style/InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fenn 3"
app:layout_constraintBottom_toTopOf="@+id/spinner6"
app:layout_constraintLeft_toLeftOf="@+id/spinner6"/>
<Spinner
android:id="@+id/spinner6"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="43dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner3"/>
<TextView
android:id="@+id/label3"
style="@style/InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fenn 4"
app:layout_constraintBottom_toTopOf="@+id/spinner7"
app:layout_constraintLeft_toLeftOf="@+id/spinner7"/>
<Spinner
android:id="@+id/spinner7"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="45dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner6"/>
<TextView
android:id="@+id/label4"
style="@style/InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fenn 5"
app:layout_constraintBottom_toTopOf="@+id/spinner8"
app:layout_constraintLeft_toLeftOf="@+id/spinner8"
/>
<Spinner
android:id="@+id/spinner8"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="43dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner7"/>
<TextView
android:id="@+id/label5"
style="@style/InputLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fenn 6"
app:layout_constraintBottom_toTopOf="@+id/spinner9"
app:layout_constraintLeft_toLeftOf="@+id/spinner9"/>
<Spinner
android:id="@+id/spinner9"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="40dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner8"/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
回答1:
Try to set a background color for the ScrollView, like:
android:background="#00FFFFFF"
Please, do not ask me why it should work :) Just try it.
来源:https://stackoverflow.com/questions/45442578/scrollview-and-spinner