performance - How to debug an unexpected Android layout? -


my constraintlayout showing strange plotting of items on app. showing elements correct positions on preview screen of android studio while running app on phone positions of elements strange.

here screen shot of app:

enter image description here

my layout is:

<?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" android:background="@drawable/background" >  <android.support.v7.widget.toolbar   xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:id="@+id/toolbar"     android:layout_width="34dp"     android:layout_height="56dp"     android:text="appbar"     android:background="@android:color/transparent"     tools:layout_editor_absolutey="25dp"     tools:layout_editor_absolutex="8dp" /> <imageview     android:id="@+id/imgbooks"     android:layout_width="272dp"     android:layout_height="302dp"     android:src="@drawable/books"     tools:layout_editor_absolutey="81dp"     tools:layout_editor_absolutex="56dp"     android:layout_centerhorizontal="true"     android:layout_below="@+id/toolbar" />  <imageview     android:id="@+id/imgname"     android:layout_width="40dp"     android:layout_height="35dp"     app:srccompat="@drawable/name"     tools:layout_editor_absolutex="16dp"     tools:layout_editor_absolutey="373dp"     android:layout_below="@+id/imgbooks"     android:layout_alignparentstart="true" /> <edittext     android:id="@+id/etemail"     android:layout_width="320dp"     android:layout_height="43dp"     android:ems="10"     android:text="email"     android:inputtype="textemailaddress"      tools:layout_editor_absolutex="67dp"     tools:layout_editor_absolutey="417dp"     android:fontfamily="avenirltstd light"     android:textcolor="#ffffff"     android:layout_above="@+id/etphone"     android:layout_toendof="@+id/imgphone" /> <imageview     android:id="@+id/imgemail"     android:layout_width="38dp"     android:layout_height="34dp"     app:srccompat="@drawable/email"     tools:layout_editor_absolutex="16dp"     tools:layout_editor_absolutey="417dp"     android:layout_aligntop="@+id/etemail"     android:layout_tostartof="@+id/etemail" />  <edittext     android:id="@+id/etname"     android:layout_width="320dp"     android:layout_height="43dp"     android:ems="10"     android:inputtype="textpersonname"     android:text="name"     tools:layout_editor_absolutex="67dp"     tools:layout_editor_absolutey="373dp"     android:fontfamily="avenirltstd light"     android:textcolor="#ffffff"     android:layout_above="@+id/etemail"     android:layout_alignend="@+id/btn" /> <imageview     android:id="@+id/imgphone"     android:layout_width="35dp"     android:layout_height="31dp"     app:srccompat="@drawable/phone"     tools:layout_editor_absolutex="16dp"     tools:layout_editor_absolutey="463dp"     android:layout_aligntop="@+id/etphone"     android:layout_alignparentstart="true" /> <edittext     android:id="@+id/etphone"     android:layout_width="320dp"     android:layout_height="43dp"     android:ems="10"     android:inputtype="phone"     android:text="phone"     tools:layout_editor_absolutex="67dp"     tools:layout_editor_absolutey="463dp"     android:fontfamily="avenirltstd light"     android:textcolor="#ffffff"     android:layout_above="@+id/btn"     android:layout_alignstart="@+id/etname"     android:layout_alignend="@+id/btn" />  <button     android:id="@+id/btn"     android:layout_width="344dp"     android:layout_height="48dp"     android:text="download brochure"     android:layout_gravity="center_vertical|center_horizontal"     tools:layout_editor_absolutex="20dp"     tools:layout_editor_absolutey="514dp"     android:fontfamily="avenirltstd light"     android:textcolor="#ffffff"     android:background="@drawable/curves"     android:layout_alignparentbottom="true"     android:layout_centerhorizontal="true" />  </android.support.constraint.constraintlayout> 

the problem not using constraints @ whole point of constraint layout.

for example, if don't use constraints on download brochure button , use tools:layout_editor_absolutex , tools:layout_editor_absolutey attributes, button stays @ position put on editor when compile app, button goes top left corner.

you need add download brochure button, set location. on same position in every possible situation.

  • app:layout_constraintleft_toleftof="parent",

  • app:layout_constraintright_torightof="parent"

but suggest on editor while playing around constraint layout easier.

you can watch video. https://www.youtube.com/watch?v=so9ax87hq9c. helps lot.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -