我正在开发一个Android应用程序,我正在尝试在androidstudio中实现设计布局
Image in Android Studio Preview
但当我在真正的设备上运行它时,它的布局就像
Design In Real Device
在Android工作室中,我使用nexus4来设计布局,我的手机分辨率是720x1280。
这是我的xml代码
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.usmanali.childsafety.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="275sp"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="3dp">
<ImageView
android:id="@+id/imgschool"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/im"
android:contentDescription="@string/todo" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="115sp"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="278dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/download" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="110sp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="393dp"
tools:ignore="MissingConstraints">
<Button
android:id="@+id/btnlogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/btnregister"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="@string/login"
android:textStyle="bold"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="291dp" />
<Button
android:id="@+id/btnregister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="@string/sign_up"
android:textStyle="bold"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="340dp" />
</RelativeLayout>