项目不';不要停留在Android Studio中使用拖放功能的位置

项目不';不要停留在Android Studio中使用拖放功能的位置,android,android-studio,drag-and-drop,emulation,Android,Android Studio,Drag And Drop,Emulation,因此,Android Studio在设计选项卡中具有拖放功能。我能够将元素放置在我想要的地方,并且布局在屏幕上看起来很棒 然而,当我运行应用程序模拟器时,它看起来完全不同。所有的东西都被推到屏幕的左上角,离我在设计模式下放置的地方很远 有没有一种方法可以让您的元素在模拟器中以与在设计模式中放置它们相同的方式显示?现在我每次都得回去编辑所有的代码 下面是我的代码,下面还有一个图片链接来进一步阐明我的观点 android的拖放操作只会将对象放在屏幕内。要使其保持不变,您应该修改xml,使对象相互约束

因此,Android Studio在设计选项卡中具有拖放功能。我能够将元素放置在我想要的地方,并且布局在屏幕上看起来很棒

然而,当我运行应用程序模拟器时,它看起来完全不同。所有的东西都被推到屏幕的左上角,离我在设计模式下放置的地方很远

有没有一种方法可以让您的元素在模拟器中以与在设计模式中放置它们相同的方式显示?现在我每次都得回去编辑所有的代码

下面是我的代码,下面还有一个图片链接来进一步阐明我的观点


android的拖放操作只会将对象放在屏幕内。要使其保持不变,您应该修改xml,使对象相互约束


您可以使用相对布局或约束布局,以便在设计布局时更轻松。

我找到了它。我使用的是“约束布局”,我需要使用“相对布局”。

不建议使用拖放。您应该发布代码。使用线性布局拖放只能通过设置来工作约束或不同的设备具有不同的屏幕大小,可能无法按预期工作。
<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.luke.currencyconverter.MainActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Enter The Amount in Dollars"
        tools:layout_editor_absoluteX="-159dp"
        tools:layout_editor_absoluteY="126dp" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="403dp"
        android:layout_height="0dp"
        android:text="Enter The Amount in Dollars:"
        android:textColor="@android:color/black"
        android:textSize="22sp"
        tools:layout_editor_absoluteX="33dp"
        tools:layout_editor_absoluteY="365dp" />

    <ImageView
        android:id="@+id/currency"
        android:layout_width="361dp"
        android:layout_height="450dp"
        app:srcCompat="@drawable/currency"
        tools:layout_editor_absoluteX="12dp"
        tools:layout_editor_absoluteY="-117dp" />

    <Button
        android:id="@+id/convert"
        android:layout_width="361dp"
        android:layout_height="wrap_content"
        android:onClick="convert"
        android:text="Convert"
        tools:layout_editor_absoluteX="12dp"
        tools:layout_editor_absoluteY="462dp" />

    <EditText
        android:id="@+id/dollarField"
        android:layout_width="368dp"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="numberDecimal"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="408dp" />

</android.support.constraint.ConstraintLayout>