[英]Android Constraint Layout margins change then revert back
設置所有四個布局約束后,我嘗試設置邊距。 邊距變形為所需的 UI(照片 #2),但隨后立即恢復為原始形式(照片 #1)。 這有效地消除了對邊距設置的更改。 照片#3 是一個更明顯的問題示例。 有誰知道出了什么問題?
奇怪的 UI 結果(與 1 和 2 分開,是問題的一個例子)
<?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>
layout_margin 設置為 8dp,因此我對四個指定邊距(即 layout_marginTop、layout_marginLeft 等)所做的每一次更改都不會“粘住”,而是恢復為指定的默認值 8dp。
我現在正在為此苦苦掙扎,您找到解決方案了嗎? 謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.