Java 安卓工作室布局债券

Java 安卓工作室布局债券,java,android,android-studio,Java,Android,Android Studio,我用几个按钮和文本视图为我的活动做了一个布局。 但有一个问题。 如果我试图移动任何按钮或文本,整个事情就会变得一团糟,我的意思是其他所有的东西都会移动,就像它们都通过一些键连接在一起一样。 我如何打破这些束缚,使它们都独立? 我试着编辑xml,但没用,他们仍然在互相跟踪。 这是一个按钮,例如: <Button android:layout_width="wrap_content" android:layout_height="wrap_content" androi

我用几个按钮和文本视图为我的活动做了一个布局。 但有一个问题。 如果我试图移动任何按钮或文本,整个事情就会变得一团糟,我的意思是其他所有的东西都会移动,就像它们都通过一些键连接在一起一样。 我如何打破这些束缚,使它们都独立? 我试着编辑xml,但没用,他们仍然在互相跟踪。 这是一个按钮,例如:

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Calculate"
    android:id="@+id/buttonFcalculate"
    android:layout_alignParentBottom="true"
    android:layout_alignRight="@+id/textFacc"
    android:layout_alignEnd="@+id/textFacc"
    android:layout_marginBottom="87dp" />

我删除了android:layout_alignEnd=“@+id/textFacc,但它仍然是一样的 请帮忙。 如果需要,我可以发布图片或代码。 提前谢谢

编辑:



我不确定问题出在哪里,但我认为,由于您使用的android:layout align,所有东西都连接起来了

我建议您将
线性布局
方向:垂直
一起使用

我制作了这个xml,检查它是否适合您:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="cannon.gaming.physicsdroid.ForceActivity"
android:orientation="vertical">

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Force"
    android:id="@+id/textForce" />
<Spinner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/spinner3"
    android:layout_marginTop="29dp" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Mass (in kilograms):"
    android:id="@+id/textFmass"
    android:layout_marginTop="12dp" />
<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="numberDecimal|numberSigned"
    android:ems="10"
    android:id="@+id/editText"
    android:layout_marginBottom="64dp" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Acceleration (in m/s²):"
    android:id="@+id/textFacc"/>
<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="numberDecimal|numberSigned"
    android:ems="10"
    android:id="@+id/editText2"
    android:layout_above="@+id/buttonFcalculate"
    android:layout_marginBottom="31dp" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Calculate"
        android:id="@+id/buttonFcalculate"
        android:layout_marginBottom="87dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="="
        android:id="@+id/textFequal"
        android:layout_marginLeft="22dp"
        android:layout_marginStart="22dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="0"
        android:id="@+id/textFresult"
        android:layout_marginLeft="32dp"/>
</LinearLayout>


请张贴整个版面
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="cannon.gaming.physicsdroid.ForceActivity"
android:orientation="vertical">

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Force"
    android:id="@+id/textForce" />
<Spinner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/spinner3"
    android:layout_marginTop="29dp" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Mass (in kilograms):"
    android:id="@+id/textFmass"
    android:layout_marginTop="12dp" />
<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="numberDecimal|numberSigned"
    android:ems="10"
    android:id="@+id/editText"
    android:layout_marginBottom="64dp" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Acceleration (in m/s²):"
    android:id="@+id/textFacc"/>
<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="numberDecimal|numberSigned"
    android:ems="10"
    android:id="@+id/editText2"
    android:layout_above="@+id/buttonFcalculate"
    android:layout_marginBottom="31dp" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Calculate"
        android:id="@+id/buttonFcalculate"
        android:layout_marginBottom="87dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="="
        android:id="@+id/textFequal"
        android:layout_marginLeft="22dp"
        android:layout_marginStart="22dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="0"
        android:id="@+id/textFresult"
        android:layout_marginLeft="32dp"/>
</LinearLayout>