我面临一个奇怪的情况,我设计了一个片段来包含一个ScrollView
但是当我转到另一个片段并从后台堆栈返回时
View
已转换为另一个不是ScrollView
的视图且屏幕项重叠
片段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:gravity="center"
tools:context="com.eh.waseldriver.TripDetailsFragment"
tools:layout_editor_absoluteY="25dp">
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/include"
layout="@layout/trip_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"></include>
<Button
android:id="@+id/btn_cancel_trip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:background="@drawable/withoutbackgroundcolor"
android:gravity="center"
android:padding="10dip"
android:text="طلب إلغاء الرحله"
android:textColor="@color/md_white_1000"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recy_decoming_trips"
app:layout_constraintVertical_bias="1.0" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recy_decoming_trips"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/include"
app:layout_constraintEnd_toEndOf="@+id/include"
app:layout_constraintStart_toStartOf="@+id/include"
app:layout_constraintTop_toBottomOf="@+id/include" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
以下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"
tools:context="com.eh.waseldriver.ReportFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:text="من فضلك إدخل التفاصيل التى تود الابلاغ عنها"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/et_report"
android:layout_width="268dp"
android:layout_height="123dp"
android:layout_marginTop="48dp"
android:ems="10"
android:inputType="textMultiLine"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
<Button
android:id="@+id/bt_send_report"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_marginBottom="8dp"
android:background="@drawable/edittext_style"
android:text="إرسال"
android:textColor="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
请注意,ConstraintLayout
代码已关闭,但未在上方
你也可以查看这个GIF,看看它可能有助于调查什么是错误的
我想知道原因以及如何解决它