左侧按钮的边距不断变化,您可以在视频中看到,我希望它们不会改变。
我正在做一个计算器,我想在不改变边距的情况下移动所有按钮。
视频在那里:https://youtu.be/UT3zINpaMhY
以下是代码:
<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.a3ibm.calculator.MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintBaseline_toBaselineOf="@+id/button2"
app:layout_constraintRight_toLeftOf="@+id/button2"
android:layout_marginRight="86dp" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.864"
app:layout_constraintVertical_bias="0.319" />
</android.support.constraint.ConstraintLayout>
答案 0 :(得分:0)
这是您想要的可能解决方案。问题在于居中:
<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintEnd_toStartOf="@+id/button2"
android:layout_marginEnd="56dp"
android:layout_marginRight="56dp"
app:layout_constraintTop_toTopOf="@+id/button2"
app:layout_constraintBottom_toBottomOf="@+id/button2"
app:layout_constraintVertical_bias="0.0" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
tools:layout_editor_absoluteY="186dp"
tools:layout_editor_absoluteX="208dp" />
</android.support.constraint.ConstraintLayout>