1
Good morning, everyone. I have a problem in my application: I have a screen to register devices, as image below, however, when enabling a field for typing, the keyboard does not override the button:
What left me with more doubt, is that I have another layout in which this does not occur:
Both buttons have the same encoding:
BUTTON SAVE DEVICE
<Button
android:id="@+id/btn_gravaDisp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:text="Gravar Dispositivo"
android:background="@color/colorPrimaryDark"
android:textColor="@android:color/white"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"/>
USER SAVE BUTTON
<Button
android:id="@+id/btn_gravaUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:text="Gravar Usuário"
android:background="@color/colorPrimaryDark"
android:textColor="@android:color/white"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"/>
I checked in some other posts that there is an option of adjustPan, however, both these classes extend Fragment, not to the Appcompatactivity.
Below, java code of both classes:
Register Device:
public class CadastrarDispositivos extends Fragment {
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getActivity().setTitle("Cadastro de Dispositivos");
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.cadastrodispositivos, container,
false);
}
}
Users:
public class Usuarios extends Fragment {
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getActivity().setTitle("Usuários");
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.usuarios, container, false);
}
}
Xml of device registration:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputLayout
android:id="@+id/inputNomeDisp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/editNomeDisp"
android:hint="Nome do dispositivo"
android:textColorHint="@color/colorPrimaryDark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:maxLength="20"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_below="@id/inputNomeDisp"
android:id="@+id/inputTipoDisp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/editTipoDisp"
android:layout_width="match_parent"
android:hint="Tipo do dispositivo"
android:textColorHint="@color/colorPrimaryDark"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:maxLength="20"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_below="@id/inputTipoDisp"
android:id="@+id/inputLocalDisp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/editLocalDisp"
android:layout_width="match_parent"
android:hint="Local do dispositivo"
android:textColorHint="@color/colorPrimaryDark"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:maxLength="20"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_below="@id/inputLocalDisp"
android:id="@+id/inputPortaDisp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/editPortaDisp"
android:layout_width="match_parent"
android:hint="Porta do dispositivo"
android:textColorHint="@color/colorPrimaryDark"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:maxLength="20"
android:inputType="number"/>
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/btn_gravaDisp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:text="Gravar Dispositivo"
android:background="@color/colorPrimaryDark"
android:textColor="@android:color/white"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"/
</RelativeLayout>
Xml of user registration:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputLayout
android:id="@+id/inputNomeUsuario"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/editNomeUsuario"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:hint="Nome do usuario"
android:textColorHint="@color/colorPrimaryDark"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/inputSenhaUsuario"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/inputNomeUsuario">
<android.support.design.widget.TextInputEditText
android:id="@+id/editSenhaUsuario"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:hint="Senha do usuario"
android:textColorHint="@color/colorPrimaryDark"/>
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatTextView
android:layout_below="@id/inputSenhaUsuario"
android:id="@+id/txtAdministrador"
android:layout_margin="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Administrador?"
android:textSize="20dp"
android:textColor="@color/colorPrimaryDark"/>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/cbx_Sim"
android:text="Sim"
android:textSize="20dp"
android:textColor="@color/colorPrimaryDark"
android:layout_below="@id/txtAdministrador"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/cbx_Nao"
android:text="Não"
android:textSize="20dp"
android:textColor="@color/colorPrimaryDark"
android:layout_below="@id/cbx_Sim"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn_gravaUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:text="Gravar Usuário"
android:background="@color/colorPrimaryDark"
android:textColor="@android:color/white"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"/>
</RelativeLayout>
From now on I thank anyone who can help me!
Thanks!
I think the layout that covers is a Linearlayout and what does not cover is a Scrollview
– Reginaldo Rigo
Possible duplicate of Android keyboard does not override buttons
– Derlei Lisboa
The two Fragments are added in the same Activity?
– mrocigno