Android Studio 不断用固定的 dp 值替换 match_parent

标签 android android-studio

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>

最佳答案

enter image description here

如图所示进行操作

关于Android Studio 不断用固定的 dp 值替换 match_parent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43452384/

相关文章:

android - 在 PhoneGap 应用程序上对我的 node.js 服务器执行授权(通过 facebook)REST 请求

android - 使用回调/监听器链接 RxJava 可观察对象

android - 进度对话框样式

Android - 如何更改 SQLite 表列。(添加新列)

java - 我想在单击时为 gridview 打开新 Activity

java - 从 Firebase 数据库获取随机值

java - Android Studio : Add radiobutton string to database

android - Android Studio 插件 Fabric 中的异常

android - 如何在 Android Studio 2 中查找未翻译的字符串

Android 预览构建工具 alpha 5 不会部署 APK