【问题标题】:android make editText floating when virtual keyboard shown, without resize backgroundandroid在显示虚拟键盘时使editText浮动,而不调整背景大小
【发布时间】:2015-05-14 19:11:06
【问题描述】:

我的活动背景中有一个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>

【问题讨论】:

    标签: android android-layout android-edittext android-virtual-keyboard


    【解决方案1】:

    尝试将以下行添加到您的 AndroidManifest.xml

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

    更多信息可以在hereandroid:windowSoftInputMode下找到

    【讨论】:

    • Surface View 向上移动,我的视频也随之向上移动。我需要我的视频保持固定,仅编辑文本以浮动在虚拟键盘上
    • 我不认为你想要的可以通过自动方式实现。您可以检测出现的软键盘,然后使用翻译动画或设置其布局参数来移动编辑文本。阻止视频上移的动机是什么?
    • 如何实现?这个事件发生在哪里?
    • 可以查看软键盘出现时应该调用的onConfigurationChanged方法。但是,当旋转屏幕和其他影响 UI 的事件时,将调用此方法。另外,看看这个答案stackoverflow.com/questions/25216749/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-18
    • 1970-01-01
    • 1970-01-01
    • 2017-10-16
    • 1970-01-01
    相关资源
    最近更新 更多