【发布时间】:2020-05-08 04:26:46
【问题描述】:
设置所有四个布局约束后,我尝试设置边距。边距变形为所需的 UI(照片 #2),但随后立即恢复为原始形式(照片 #1)。这有效地消除了对边距设置的更改。照片#3 是一个更明显的问题示例。有谁知道怎么回事?
1
UI before and after adding margin (there is no change)
2
desired UI (effect the margin should have)
3
strange UI result (separate from 1 & 2, is an example of the problem)
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
tools:context=".SettingsActivity">
<TextView
android:id="@+id/settingsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:textColor="@android:color/white"
android:textSize="36sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="@+id/turnSettingSpinner"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="100dp"
android:background="@android:color/white"
android:entries="@array/turn_settings"
android:spinnerMode="dropdown"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/settingsTextView" />
</androidx.constraintlayout.widget.ConstraintLayout>
【问题讨论】:
-
显示你想要的预期用户界面吗?
-
照片 #2 是所需的 UI,照片 #1 是结果,与边距限制无关
标签: android android-constraintlayout layoutmargins