I have an EditText in the lower part of my Android screen as shown in image. Due to some project contraints I'm supposed to use only Absolute positioning.
When clicked on the EditText the soft keyboard hides the EditText as shown in the other image.
I have tried putting android:windowSoftInputMode="adjustResize" in the manifest file (also tried adjustPan) It only works for relative positioning (commented textField_layoutparams code below) but doesn't seems to be working for absolute positioning.
Even tried putting a ScrollView (commented code below) but it doesn't work.
Code:
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val scrollView: ScrollView
val relativeLayout: RelativeLayout
val textField: EditText
/*scrollView = ScrollView (this)
scrollView.layoutParams = RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT
)*/
//scrollView.isFillViewport = true
//setContentView(scrollView)
relativeLayout = RelativeLayout(this)
relativeLayout.layoutParams = RelativeLayout.LayoutParams (
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT
)
relativeLayout.setBackgroundColor(Color.parseColor("#0000FF"))
//scrollView.addView(relativeLayout)
setContentView (relativeLayout)
textField = EditText(this)
val textField_layoutparams: LayoutParams
textField_layoutparams = RelativeLayout.LayoutParams (
400,
150
)
textField.setBackgroundColor(Color.parseColor("#FFFFFF"))
//textField_layoutparams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE)
//textField_layoutparams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE)
//textField_layoutparams.setMargins(0, 0, 0, 200)
textField.layoutParams = textField_layoutparams
textField.hint = "Enter Text"
textField.x = 500F
textField.y = 2200F
relativeLayout.addView(textField)
}
/**
* A native method that is implemented by the 'scrollviewpoc' native library,
* which is packaged with this application.
*/
external fun stringFromJNI(): String
companion object {
// Used to load the 'scrollviewpoc' library on application startup.
init {
System.loadLibrary("scrollviewpoc")
}
}
}
Is there any way to achieve the desired behaviour in case of Absolute positioning?


I think that issue generated when you tried to set
EditTextx and y from Kotlin side.the property
android:windowSoftInputMode="adjustResize"into inManifest.that is work for all Android device, but in your case i noticed a difference when you set X and Y programmatically.