Android Studio不断用固定的dp值替换match_parent [英] Android studio keeps replacing match_parent with fixed dp value

查看:77
本文介绍了Android Studio不断用固定的dp值替换match_parent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android Studio(v 2.3.1)一直用固定的dp替换替换RelativeLayout的match_parent.例如,当我输入match_parent作为宽度时,它将替换为368dp.在测试应用程序时,我发现RelativeLayout确实是错误的.

Android studio (v 2.3.1) keeps replacing the match_parent of a RelativeLayout with a fixed dp vanue. For example, when I type match_parent as the width, it replaces it with 368dp. When I test the app, I see that the RelativeLayout indeed is wrong.

有人知道如何解决此问题吗?

Does anyone know how to fix this?

<?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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆