简体   繁体   English

当显示虚拟键盘时,android使editText浮动,而无需调整背景大小

[英]android make editText floating when virtual keyboard shown, without resize background

I have a surfaceView in the background of my activity and edit text over it, i need to show edit text when virtual keyboard is shown withouth resizing surfaceView... At the end I need only edit text to move when virtual keyboard is shown 我在活动的背景中有一个SurfaceView并在其上编辑文本,当显示虚拟键盘时,我需要显示编辑文本,而无需调整SurfaceView的大小...最后,当显示虚拟键盘时,我只需要编辑文本即可移动

<?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>

Try adding the following line to your AndroidManifest.xml 尝试将以下行添加到您的AndroidManifest.xml中

    <activity
        android:name="YourActivityName"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:windowSoftInputMode="adjustPan" >
    </activity>

More info on it can be found here under android:windowSoftInputMode 它更多信息,可以发现在这里android:windowSoftInputMode

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

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