AndroidStudio - TextInput hide characters when keyboard shows up - java

When I try to enter characters in my TextInputEdit I can't see them while keyboard is shown up.
It happens only with the last textinputedit in my activity, other works perfectly. When I hide my keyboard - characters appears, but when I try to add some again I cant see any changes until keyboard hides.
My xml of activity:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".Registration"
android:id="#+id/app_bar">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/regEmailwrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/regEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Your Email *"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/regNamewrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/regEmailwrapper"
tools:layout_editor_absoluteX="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/regName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="First name" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/regSurnameWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/regNamewrapper"
tools:layout_editor_absoluteX="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/regSurname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Last name" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/regPasswordwrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/regSurnameWrapper"
tools:layout_editor_absoluteX="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/regPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Password *"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/regPassword2wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/regPasswordwrapper"
tools:layout_editor_absoluteX="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/regPassword2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Password again *"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="#+id/signUp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Sign up!"
app:layout_constraintTop_toBottomOf="#+id/genderDropdown"
tools:layout_editor_absoluteX="0dp" />
<Spinner
android:id="#+id/genderDropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:spinnerMode="dropdown"
app:layout_constraintTop_toBottomOf="#+id/regPassword2wrapper"
tools:layout_editor_absoluteX="0dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
How can i fix it?

Add this properties :
android:windowSoftInputMode="adjustPan|adjustResize"
to your Activity tag in AndroidManifest.xml

You can wrap your ConstraintLayout inside ScrollView so you can easily scroll view when you can't see TextInput
<ScrollView 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:fillViewport="true">
This should be enough. I think there's no need to add anything inside Manifest

Related

Specific Layout positioning in Android

I know this is common to ask but I'm having a trouble on how can I place the change password button beside edit button like the example image below, I tried app:layout_constraintLeft_toLeftOf="id" but it doesn't work, Is there anyway how can I manage in layout, I've keep searching till yet not found the answer, need help
**activity_main.xml **
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="#+id/activity_profile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".EditProfile">
<ScrollView
android:id="#+id/scrolView_account"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/linear_account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="50dp"
android:background="#color/primary" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
android:padding="5dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="50dp"
android:layout_marginRight="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="10dp"
android:id="#+id/txtProfileDetails"
android:text="Profile Details"
android:textStyle="bold" />
<Button
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
app:layout_constraintLeft_toLeftOf="parent"
android:padding="10dp"
android:layout_marginRight="10dp"
android:id="#+id/editProfile"
android:drawableLeft="#drawable/ic_edit"
android:textStyle="bold" />
<Button
android:layout_width="205dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
app:layout_constraintLeft_toLeftOf="parent"
android:padding="10dp"
android:layout_marginRight="10dp"
android:id="#+id/editPassword"
android:text="Change Password"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/cc_idno"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:helperText="Mandatory"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
app:helperTextTextColor="#color/validation"
app:startIconDrawable="#drawable/ic_series"
android:layout_below="#+id/txtProfileDetails"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="ID number"
android:id="#+id/edt_idno"
android:inputType="text"
android:layout_below="#id/edtFirstname"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imageview_account_profile"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/user_logo"
app:civ_border_color="#FFFFFF"
app:civ_border_width="2dp" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/imageview_account_profile"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Wrap your both the concerned buttons inside a linearlayout and it will work. with horizontal orientation .
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right">
<Button
android:id="#+id/editPassword"
android:layout_width="205dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:padding="10dp"
android:text="Change Password"
android:textStyle="bold"
/>
<Button
android:id="#+id/editProfile"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:padding="10dp"
android:textStyle="bold"
/>
</LinearLayout>

Hint and User Input overlaying in a TextView

I've never seen this happen before, and have no idea what is causing it, my first choice was to hide hint with a piece of java code within the fragment, but I failed so hard at in that now I just wanna find a XML solution.
This is happening to every field, and I can't find anything wrong with the layout here, any insights?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_nome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_nome_contato"
android:inputType="textPersonName"
android:lines="1"
android:padding="10dp"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_telefone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_telefone_contato"
android:inputType="phone"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_email_contato"
android:inputType="textEmailAddress"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_nome_empresa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_empresa_contato"
android:inputType="text"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_telefone_empresa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_tel_empresa_contato"
android:inputType="phone"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_matricula"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Digite sua matricula (Opcional)"
android:inputType="number"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<sinapse.com.br.estilo.component.CustonSpinner
android:id="#+id/faq_contato_spinner_assunto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:hintText="#string/title_spinner" />
<EditText
android:id="#+id/faq_contato_campo_mensagem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginEnd="2dp"
android:layout_marginStart="2dp"
android:gravity="center_horizontal|bottom"
android:hint="#string/hint_areamensagem"
android:inputType="textMultiLine" />
<TextView
android:id="#+id/faq_contato_numero_caracteres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="#string/caracteres" />
<com.google.android.material.button.MaterialButton
android:id="#+id/faq_contato_btn_enviar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:layout_gravity="right"
android:text="#string/enviar" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/faq_contato_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="13dp" />
</LinearLayout>
</ScrollView>
The problem is you setting a padding to your EditText, that's why the EditText components are not being given enough space to accommodate user's input without having to overlay with the hint. Simply get rid of paddings in your EditText components and it will run just fine. :)
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_telefone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_telefone_contato"
android:inputType="phone"
android:lines="1"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
If you DO NOT want your hint to float. (If you want your hint to completely disappear as soon as the user taps on the EditText box)
You can add app:hintEnabled="false" in your TextInputLayout.
In this case, I think you can safely add your padding back on because the hint will disappear on user's tap.
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintEnabled="false">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_telefone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_telefone_contato"
android:inputType="phone"
android:lines="1"
android:padding="10dp"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
Try with the following code may be it will help you.
//Remove padding from edittext
//Try to set hint on TextInputLayout instead of EditText
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_nome_contato">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/faq_contato_nome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:lines="1"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>

Android ScrollView SearchBar

I am trying to build a searchbar over a full screen image slider who can be scrolled.
Image 1
But when i am scrolling down, my logo and searchbar are scrolled too.
Image 2
How can i do to be fixed even i scroll down or not?
This is my xml file. I need that imageslider to be fullscreen when i open the activity.
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.denzcoskun.imageslider.ImageSlider
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:iss_auto_cycle="true"
app:iss_corner_radius="5"
app:iss_delay="0"
app:iss_period="1000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:src="#drawable/logo" />
<SearchView
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="#string/searchint"
android:background="#drawable/bg_round"
android:queryBackground="#color/transparent"
android:queryHint="SEARCH PRODUCTS"
android:theme="#style/SearchViewStyle" />
</LinearLayout>
</com.denzcoskun.imageslider.ImageSlider>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/emaillogare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autofillHints="#string/email"
android:drawableStart="#drawable/email"
android:drawablePadding="10sp"
android:ems="10"
android:hint="#string/email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:padding="20sp"
android:textColor="#color/white"
android:textColorHint="#color/white" />
<EditText
android:id="#+id/logareparola"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autofillHints="#string/parola"
android:drawablePadding="10sp"
android:ems="10"
android:hint="#string/parola"
android:inputType="textPassword"
android:maxLines="1"
android:padding="20sp"
android:textColor="#color/white"
android:textColorHint="#color/white" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="#color/white"
android:paddingStart="30sp"
android:textColor="#color/white" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</androidx.drawerlayout.widget.DrawerLayout>
Separate your search bar such that it resides outside of the ScrollView.
<ParentLayout>
<LayoutContainingSearchBar>
---- Search Bar related items
</LayoutContainingSearchBar>
<SrollView>
---- Scrollable Area
</SrollView>
</ParentLayout>
Try the code below and if the problem persists, let me know.
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<SearchView
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="#string/searchint"
android:background="#drawable/bg_round"
android:queryBackground="#color/transparent"
android:queryHint="SEARCH PRODUCTS"
android:theme="#style/SearchViewStyle" />
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.denzcoskun.imageslider.ImageSlider
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:iss_auto_cycle="true"
app:iss_corner_radius="5"
app:iss_delay="0"
app:iss_period="1000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:src="#drawable/logo" />
</LinearLayout>
</com.denzcoskun.imageslider.ImageSlider>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/emaillogare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autofillHints="#string/email"
android:drawableStart="#drawable/email"
android:drawablePadding="10sp"
android:ems="10"
android:hint="#string/email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:padding="20sp"
android:textColor="#color/white"
android:textColorHint="#color/white" />
<EditText
android:id="#+id/logareparola"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autofillHints="#string/parola"
android:drawablePadding="10sp"
android:ems="10"
android:hint="#string/parola"
android:inputType="textPassword"
android:maxLines="1"
android:padding="20sp"
android:textColor="#color/white"
android:textColorHint="#color/white" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="#color/white"
android:paddingStart="30sp"
android:textColor="#color/white" />
</LinearLayout>
</LinearLayout>
</androidx.drawerlayout.widget.DrawerLayout>
Feel free to ask if something is unclear.

Android SearchView overlapping

I need to build a searchview who is fixed on top of the page.
When i scroll down my searchview is overlapped by a imageslider Image 1 all i need to do is to be always in front to be visible.
I tried everything but always my searchview is in the back of other objects. Any suggestions?
This is my xml file.
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:src="#drawable/logo" />
<SearchView
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="#string/searchint"
android:background="#drawable/bg_round"
android:queryBackground="#color/transparent"
android:queryHint="SEARCH PRODUCTS"
android:theme="#style/SearchViewStyle" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autofillHints="#string/email"
android:drawableStart="#drawable/email"
android:drawablePadding="10sp"
android:ems="10"
android:hint="#string/email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:padding="20sp"
android:textColor="#color/white"
android:textColorHint="#color/white" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autofillHints="#string/parola"
android:drawablePadding="10sp"
android:ems="10"
android:hint="#string/parola"
android:inputType="textPassword"
android:maxLines="1"
android:padding="20sp"
android:textColor="#color/white"
android:textColorHint="#color/white" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="#color/white"
android:paddingStart="30sp"
android:textColor="#color/white" />
</LinearLayout>
<com.denzcoskun.imageslider.ImageSlider
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:iss_auto_cycle="true"
app:iss_corner_radius="5"
app:iss_delay="0"
app:iss_period="1000"></com.denzcoskun.imageslider.ImageSlider>
</LinearLayout>
</ScrollView>
</androidx.drawerlayout.widget.DrawerLayout>
You can use elevation to make it at top of other elements
Solution Code:
<SearchView
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="#string/searchint"
android:background="#drawable/bg_round"
android:queryBackground="#color/transparent"
android:elevation="20dp"
android:queryHint="SEARCH PRODUCTS"
android:theme="#style/SearchViewStyle" />
For instance, I used 20dp, you use your preferred value instead.
Feel free to ask if something is unclear.

Stick header at top when Softkeyboard is opened android

I have a layout, in which I need that the top header should should not hide when I open softKeyBoard. I am using Fragment here.I am using recylerView.
when i am opening softkeyboard the top header is scrolling up. I need that header to stay there and Recyclerview to scroll.
Below is my xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rel_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bggradient">
<RelativeLayout
android:id="#+id/rel_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/drawable_below_line">
<ImageView
android:id="#+id/iv_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtSettingHeader"
android:layout_alignTop="#+id/txtSettingHeader"
android:layout_centerVertical="true"
android:background="#drawable/button_selector"
android:onClick="onClickEvent"
android:padding="10dp"
android:src="#mipmap/ic_back" />
<TextView
android:id="#+id/txtUserName"
style="#style/FragHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
<ImageView
android:id="#+id/iv_userImage"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtUserName"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/txtUserName"
android:layout_centerVertical="true"
android:onClick="onViewClick"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:src="#mipmap/ic_male" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/lin_comment"
android:layout_below="#+id/rel_header"
android:gravity="top"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/RecyelerViewChat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
</android.support.v7.widget.RecyclerView>
<TextView
android:id="#+id/tv_txtNoRecords"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:minHeight="100dp"
android:text="#string/txtNoChat"
android:textColor="#android:color/white"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#70FFFFFF"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp">
<LinearLayout
android:id="#+id/linEditComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusableInTouchMode="true"
android:orientation="horizontal">
<ImageView
android:id="#+id/iv_imgToggleKeyboardEmoji"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:src="#mipmap/ic_emoji" />
<com.lawo.emojicon.EmojiconEditText
android:id="#+id/et_edtChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/drawable_black_border"
android:hint="#string/hintTypeMessage"
android:inputType="textNoSuggestions|textMultiLine"
android:maxLength="500"
android:maxLines="3"
android:padding="10dp"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray" />
</LinearLayout>
<ImageView
android:id="#+id/iv_imgSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="onClickEvent"
android:padding="10dp"
android:src="#mipmap/ic_sent" />
</LinearLayout>
</RelativeLayout>
Add the following to your "activity" tag in AndroidManifest.xml:
android:windowSoftInputMode="adjustResize"
Reference: Specify How Your UI Should Respond.

Categories

Resources