title: Alignment Layout exchange between classes - Android Studio
body: <p>I am implementing a program that uses <strong>database</strong> and interacts with different <code>layouts</code> of entries and editing users.</p>
  
  <p>I'm working with <code>RelativeLayout</code> on all screens. In one of the<code>layouts</code>, I insert a perfectly aligned button and give the <strong>command</strong> <code>android:visibility="gone"</code> for him to show upon request.</p>
  
  <p>The problem is that when I need to use it at <strong>command</strong> <code>editarBt.setVisibility(View.VISIBLE)</code>, the <strong>button</strong> appears out of alignment and overlaps the fields for entering information.</p>
  
  <p>Is there any way to keep the <strong>position</strong> of command by <strong>button</strong>?</p>
  
  <p>I will not put the entire code because it has 7 classes, so I'll just put the classes that interest.</p>
  
  <p><strong>EnterPatientActivity Class</strong></p>
  
  <pre><code>package br.luizhmu.aulas_android_sqlite;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  /**
  * Created by LuizHMU on 2/17/15.
  */
  public class EnterPatientActivity extends Activity {
  
  private Paciente paciente = new Paciente();
  private EditText nomeEt;
  private EditText emailEt;
  private EditText senhaEt;
  private Button salvarBt;
  private Button editarBt;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_inserir_paciente);
  
      nomeEt = (EditText) findViewById(R.id.editTextNome);
      emailEt = (EditText) findViewById(R.id.editTextEmail);
      senhaEt = (EditText) findViewById(R.id.editTextSenha);
      salvarBt = (Button) findViewById(R.id.buttonSalvar);
      editarBt = (Button) findViewById(R.id.buttonEditar);
  
      Intent intent = getIntent();
      if(intent != null){
          Bundle bundle = intent.getExtras();
          if(bundle != null){
  
              paciente.setId(bundle.getLong("id"));
              paciente.setNome(bundle.getString("nome"));
              paciente.setEmail(bundle.getString("email"));
  
              nomeEt.setText(paciente.getNome());
              emailEt.setText(paciente.getEmail());
  
              senhaEt.setVisibility(View.GONE);
              salvarBt.setVisibility(View.GONE);
              editarBt.setVisibility(View.VISIBLE);
  
          }
      }
  }
  
  public void salvar(View view){
      paciente.setNome(nomeEt.getText().toString());
      paciente.setEmail(emailEt.getText().toString());
      paciente.setSenha(senhaEt.getText().toString());
  
      DataBase bd = new DataBase(this);
      bd.inserir(paciente);
  
      Toast.makeText(this, "Paciente inserido com sucesso!", Toast.LENGTH_SHORT).show();
  }
  
  
  public void editar(View view){
      paciente.setNome(nomeEt.getText().toString());
      paciente.setEmail(emailEt.getText().toString());
  
      DataBase bd = new DataBase(this);
      bd.atualizar(paciente);
  
      Toast.makeText(this, "Paciente \""+paciente.getNome()+"\" atualizado com sucesso.", Toast.LENGTH_SHORT).show();
  }
  
  }
  </code></pre>
  
  <p><strong>activity_inserir_paciente.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingLeft="15dp"
  android:paddingRight="15dp"
  android:background="#ffffea0a"
  tools:context=".EnterPatientActivity"&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceSmall"
      android:text="Novo paciente"
      android:id="@+id/textView3"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:textColor="#ff1727ff"
      android:textSize="20dp"/&gt;
  
  &lt;EditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="textPersonName"
      android:hint="*Nome"
      android:ems="10"
      android:id="@+id/editTextNome"
      android:layout_below="@+id/textView3"
      android:layout_alignRight="@+id/buttonSalvar"
      android:layout_alignEnd="@+id/buttonSalvar" /&gt;
  
  &lt;EditText
      android:hint="Telefone"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="phone"
      android:ems="10"
      android:id="@+id/editTextTelefone"
      android:layout_below="@+id/editTextNome"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true" /&gt;
  
  &lt;EditText
      android:hint="*E-mail"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="textEmailAddress"
      android:ems="10"
      android:id="@+id/editTextEmail"
      android:layout_below="@+id/editTextTelefone"
      android:layout_alignLeft="@+id/editTextTelefone"
      android:layout_alignStart="@+id/editTextTelefone" /&gt;
  
  &lt;EditText
      android:hint="*Senha"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="textPassword"
      android:ems="10"
      android:id="@+id/editTextSenha"
      android:layout_below="@+id/editTextEmail"
      android:layout_alignLeft="@+id/editTextEmail"
      android:layout_alignStart="@+id/editTextEmail" /&gt;
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Salvar"
      android:id="@+id/buttonSalvar"
      android:onClick="salvar"
      android:layout_below="@+id/textView4"
      android:layout_alignRight="@+id/editTextSenha"
      android:layout_alignEnd="@+id/editTextSenha" /&gt;
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Editar"
      android:id="@+id/buttonEditar"
      android:layout_alignTop="@+id/buttonSalvar"
      android:layout_toLeftOf="@+id/buttonSalvar"
      android:layout_toStartOf="@+id/buttonSalvar"
      android:visibility="gone"
      android:onClick="editar"/&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceSmall"
      android:text="* Campos de preenchimento obrigatório"
      android:textColor="#000000"
      android:id="@+id/textView4"
      android:layout_below="@+id/editTextSenha"
      android:layout_alignLeft="@+id/editTextSenha"
      android:layout_alignStart="@+id/editTextSenha" /&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>