简体   繁体   English

Android 在键盘顶部移动视图

[英]Android move view on top of the keyboard

I want to move an edit text on top of the keyboard when the keyboard opens.我想在键盘打开时移动键盘顶部的编辑文本。 And when the keyboard closes I want to move the view back to its original position.当键盘关闭时,我想将视图移回其原始位置。 Something like this video .有点像这个视频

Here in the video when you tap on the edit text field the keyboard opens and the view translates on top of the keyboard, now when the keyboard closes the edit text comes back to the original position.在视频中,当您点击编辑文本字段时,键盘会打开并且视图会在键盘顶部转换,现在当键盘关闭时,编辑文本会返回到原始位置。 Also, notice how any view on the background is not moving its place only edit text is moving.另外,请注意背景上的任何视图都没有移动其位置,只有编辑文本在移动。

I have done this partially by android:windowSoftInputMode in the activity.我在活动中部分通过 android:windowSoftInputMode 完成了此操作。 but doing so will move the entire activity not that only particular edit text.但这样做会移动整个活动,而不仅仅是特定的编辑文本。

So can anyone please guide me with this?那么任何人都可以请指导我吗?

In your Manifest file inside the selected activist tag add在选定的活动家标签内的清单文件中添加

android:windowSoftInputMode="adjustResize"

and in your EditText add并在您的 EditText 添加

android:layout_alignParentBottom="true"

Hope this might help希望这可能会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM