Java Android Studio预览与设备不同
我试图创建两个片段。一个包含一个微调器,另一个在从第一个片段中的微调器选择颜色时背景发生更改。功能是有(表面上)但我有困难,它实际上是如何出现在屏幕上。下面是附加的照片,我的设备和android studio预览之一。预览显然是我希望在我的设备上显示的内容。它还显示了多个微调器箭头,尽管只有一个微调器 活动\u main.xmlJava Android Studio预览与设备不同,java,android,xml,android-studio,Java,Android,Xml,Android Studio,我试图创建两个片段。一个包含一个微调器,另一个在从第一个片段中的微调器选择颜色时背景发生更改。功能是有(表面上)但我有困难,它实际上是如何出现在屏幕上。下面是附加的照片,我的设备和android studio预览之一。预览显然是我希望在我的设备上显示的内容。它还显示了多个微调器箭头,尽管只有一个微调器 活动\u main.xml <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schema
<androidx.constraintlayout.widget.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:id="@+id/paletteLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/container1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/container2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Spinner
android:id="@+id/colorSpinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/container2"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/container1">
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
对于存在类似问题的片段,必须为各个片段创建新布局。这就是我没能做到的。有关更多信息,请参阅