Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio keeps replacing match_parent with fixed dp value

Tags:

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> 
like image 842
Maarten Weyns Avatar asked Apr 17 '17 13:04

Maarten Weyns


People also ask

What is the difference between Match_parent and Wrap_content in Android?

FILL_PARENT (renamed MATCH_PARENT in API Level 8 and higher), which means that the view wants to be as big as its parent (minus padding) WRAP_CONTENT, which means that the view wants to be just big enough to enclose its content (plus padding)

What does Match_parent mean in Android?

match_parent and fill_parent are same property, used to define width or height of a view in full screen horizontally or vertically. These properties are used in android xml files like this. android:layout_width="match_parent" android:layout_height="fill_parent"


1 Answers

enter image description here

Do it like as shown in picture

like image 161
Srinivas Keerthiprakasam Avatar answered Sep 17 '22 11:09

Srinivas Keerthiprakasam