Android studio (v 2.3.1) 不断用固定的 dp vanue 替换 RelativeLayout 的 match_parent
。例如,当我输入 match_parent 作为宽度时,它会将其替换为 368dp。当我测试应用程序时,我发现RelativeLayout 确实是错误的。
有谁知道如何解决这个问题?
<?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="be.mawey.lamachat.LoginActivity">
<RelativeLayout
android:layout_width="match_parent" <!-- THIS IS BEING REPLACED WITH 368dp -->
android:layout_height="match_parent" <!-- THIS IS BEING REPLACED WITH 495dp -->
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
<Button
android:id="@+id/buttonLogin"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:background="@color/colorPrimary"
android:text="Login"
android:textColor="@android:color/white"
android:textSize="18sp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="292dp" />
<EditText
android:id="@+id/editTextCode"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="@+id/buttonLogin"
android:layout_alignParentStart="true"
android:ems="10"
android:hint="Secret code here"
android:inputType="numberPassword"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="234dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="50dp"
android:fontFamily="monospace"
android:text="example"
android:textAlignment="center"
android:textColor="@color/colorPrimaryDark"
android:textSize="36sp"
android:textStyle="italic"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="16dp" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
最佳答案
关于Android Studio 不断用固定的 dp 值替换 match_parent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43452384/