I am trying to make a layout with an Edit Text field for email requests. The design makes it so that the keyboard is always opened over the editText View which makes it impossible to know what you are entering. I have tried many suggestions on stack overflow but most of them are for API <24 (though I don't think this has much effect on this).
In the Activity file I have tried the following:
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN or WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN or WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
In Android Manifest I have also tried the following, both in conjunction and separately:
android:windowSoftInputMode="adjustPan"
android:windowSoftInputMode="stateHidden|adjustPan"
android:windowSoftInputMode="adjustResize"
I also wrapped my layout in a ScrollView as described by Heena here : https://stackoverflow.com/a/39867438/5635144
Below is my XML and the accompanying activity
<?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"
tools:context=".EmailResetActivity">
<RelativeLayout
android:id="@+id/bg"
android:layout_width="match_parent"
android:layout_height="419dp"
android:background="@drawable/signin_up_anim"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
...
</android.support.constraint.ConstraintLayout>
</RelativeLayout>
<EditText
android:id="@+id/e_request"
android:layout_width="305dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="8dp"
android:ems="10"
android:hint="@string/email_address"
android:inputType="textEmailAddress"
android:paddingStart="10dp"
android:paddingBottom="15dp"
android:textColorHint="@color/hintgrey"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.522"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bg" />
<LinearLayout
android:layout_width="wrap_content"
android:id="@+id/buttonsContainer"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/e_request">
<Button
android:id="@+id/sendRequestBtn"
android:layout_width="150dp"
android:layout_height="45dp"
android:background="@drawable/large_btn"
android:text="@string/submit"
android:textColor="@color/white" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
class EmailResetActivity : AppCompatActivity() {
lateinit private var auth: FirebaseAuth
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_email_reset)
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN or WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
auth = FirebaseAuth.getInstance()
val animDrawable = resetPassInfoBg.background as AnimationDrawable
animDrawable.setEnterFadeDuration(2500)
animDrawable.setExitFadeDuration(1500)
animDrawable.start()
sendRequestBtn.setOnClickListener(View.OnClickListener {
val email = e_request.getText().toString().trim()
if (TextUtils.isEmpty(email)) {
Toast.makeText(application, "Enter your email ", Toast.LENGTH_SHORT).show()
return@OnClickListener
}
})
}
}
I would like for the layout to be moved up so the editText Field is visible but currently nothing is making it work.