android使editText在显示虚拟键盘时浮动,无需调整背景大小
我有一个在我的活动和编辑文本的背景surfaceView,我需要显示编辑文本时,虚拟键盘显示而不调整surfaceView的大小。。。最后,当显示虚拟键盘时,我只需编辑文本即可移动android使editText在显示虚拟键盘时浮动,无需调整背景大小,android,android-layout,android-edittext,android-virtual-keyboard,Android,Android Layout,Android Edittext,Android Virtual Keyboard,我有一个在我的活动和编辑文本的背景surfaceView,我需要显示编辑文本时,虚拟键盘显示而不调整surfaceView的大小。。。最后,当显示虚拟键盘时,我只需编辑文本即可移动 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
<?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:id="@+id/main_relative_layout">
<SurfaceView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_fragment_surfase_view"
/>
<LinearLayout
android:id="@+id/main_fragment_bottom_menu_layout"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<View
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="0dp" />
<Button style="@style/RoundButtonMainScreenFragment" />
<View
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="0dp" />
<Button style="@style/RoundButtonMainScreenFragment" />
<View
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="0dp" />
<Button style="@style/RoundButtonMainScreenFragment" />
<View
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="0dp" />
<ImageButton
android:src="@android:drawable/ic_menu_camera"
style="@style/RoundButtonMainScreenFragment"
android:contentDescription="Delete" />
<View
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="0dp" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/list_view_container"
android:layout_alignParentTop="true"
android:isScrollContainer="true">
</FrameLayout>
<EditText
android:visibility="visible"
android:id="@+id/main_screen_edit_text"
android:alpha="0.5"
android:layout_above="@id/main_fragment_bottom_menu_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_gravity="bottom"/>
</RelativeLayout>
尝试将以下行添加到AndroidManifest.xml中
<activity
android:name="YourActivityName"
android:configChanges="orientation|keyboardHidden|screenSize"
android:windowSoftInputMode="adjustPan" >
</activity>
更多关于它的信息可以在android:WindowsofInputMode下找到表面视图向上移动,我的视频也随之向上移动。我需要我的视频保持固定,只编辑文本浮动在虚拟键盘上。我不认为你想要的可以通过自动方式实现。可以检测出现的软键盘,然后使用翻译动画或设置其布局参数移动编辑文本。阻止视频上移的动机是什么?如何实现?此事件发生在何处?您可以检查当软键盘出现时应调用的OnConfiguration Changed方法。但是,当旋转屏幕和其他影响UI的事件时,将调用此方法。另外,看看这个答案