2
I’m having trouble putting together a layout.
In emulated it stays the way I want as below:
But in the cell phone is completely disfigured as below:
XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/lnl_principal"
android:background="#ffe7fcff"
android:weightSum="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="185pt"
android:gravity="center"
android:id="@+id/lnl_periodo">
<LinearLayout
android:orientation="vertical"
android:layout_width="155pt"
android:layout_height="27pt"
android:id="@+id/lnl_ftp"
android:gravity="center">
<TextView
android:layout_width="150pt"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txt_hintftp"
android:text="@string/lbl_hintftp" />
<EditText
android:layout_width="155pt"
android:layout_height="wrap_content"
android:id="@+id/edt_ftp"
android:layout_gravity="center_horizontal"
android:inputType="text"
android:textColor="#010101"
android:singleLine="true"
android:editable="false" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="155pt"
android:layout_height="27pt"
android:id="@+id/lnl_porta"
android:focusableInTouchMode="true"
android:gravity="center"
android:weightSum="1">
<TextView
android:layout_width="150pt"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txt_hintport"
android:text="@string/lbl_hintport" />
<EditText
android:layout_width="155pt"
android:layout_height="match_parent"
android:id="@+id/edt_portnumber"
android:layout_gravity="center_horizontal"
android:inputType="text"
android:textColor="#010101"
android:layout_weight="0.67" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="155pt"
android:layout_height="27pt"
android:id="@+id/lnl_pasta"
android:gravity="center">
<TextView
android:layout_width="150pt"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txt_hintdir"
android:text="@string/lbl_hintdir" />
<EditText
android:layout_width="155pt"
android:layout_height="match_parent"
android:id="@+id/edt_diretorio"
android:layout_gravity="center_horizontal"
android:inputType="text"
android:textColor="#010101"
android:gravity="center|left" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="155pt"
android:layout_height="27pt"
android:id="@+id/lnl_usuario"
android:gravity="center">
<TextView
android:layout_width="150pt"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txt_hintuser"
android:text="@string/lbl_hintuser" />
<EditText
android:layout_width="155pt"
android:layout_height="match_parent"
android:id="@+id/edt_usuario"
android:layout_gravity="center_horizontal"
android:inputType="text"
android:textColor="#010101"
android:gravity="center|left" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="155pt"
android:layout_height="27pt"
android:layout_gravity="center_horizontal"
android:id="@+id/lnl_senha"
android:gravity="center">
<TextView
android:layout_width="150pt"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txt_hintpass"
android:text="@string/lbl_hintpass" />
<EditText
android:layout_width="155pt"
android:layout_height="match_parent"
android:id="@+id/edt_senha"
android:layout_gravity="center_horizontal"
android:inputType="textPassword"
android:textColor="#010101"
android:gravity="center|left" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="155pt"
android:layout_height="25pt"
android:id="@+id/lnl_excluir"
android:gravity="center">
<LinearLayout
android:orientation="vertical"
android:layout_width="76pt"
android:layout_height="match_parent"
android:id="@+id/lnl_delete"
android:gravity="center">
<TextView
android:layout_width="73pt"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txt_hintdel"
android:text="@string/lbl_hintdel" />
<Spinner
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/spn_excluir"
android:layout_weight="1"
android:gravity="left|top" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="76pt"
android:layout_height="match_parent"
android:id="@+id/lnl_tiponet"
android:gravity="center">
<TextView
android:layout_width="73pt"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txt_hintup"
android:text="@string/lbl_hintup" />
<Spinner
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/spn_tiponet"
android:layout_weight="1"
android:gravity="left|top" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="45pt"
android:id="@+id/lnl_botoes"
android:gravity="center">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn_cancelar"
android:nestedScrollingEnabled="false"
android:src="@mipmap/cancela"
android:contentDescription="btn_cancelar"
android:background="#ffe7fcff" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="20dp"
android:layout_height="match_parent"
android:id="@+id/lnl_espbtn"></LinearLayout>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn_testar"
android:src="@mipmap/testar"
android:contentDescription="btn_testar"
android:background="#ffe7fcff" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="20dp"
android:layout_height="match_parent"
android:id="@+id/lnl_espbtn2" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn_confirmar"
android:src="@mipmap/confirma"
android:contentDescription="btn_confirmar"
android:background="#ffe7fcff" />
</LinearLayout>
</LinearLayout>
I’m using LinearLayout
in all layouts.
The phone obviously has a different resolution, but how best to make the layout is usual for any equipment on screens with different resolution?
put the xml code of the layout with problem
– Skywalker
@Skywalker edited the code and entered the XML, please take a look.
– Fábio Azevedo
that question is a good starting point.
– emanuelsn
Your phone and emulator have equal screen resolutions ?
– Pedro Laini
It may have nothing to do with it, but you realize you’re using it
fill_parent
for width and height of parent layout? Tries to switch tomatch_parent
and rotate.– Erick Filho
@Pedrolaini, yes.... are different resolutions...
– Fábio Azevedo
then see my answer
– Pedro Laini