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>
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)
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"
Do it like as shown in picture
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With