Android 软键盘隐藏编辑文本

Android 软键盘隐藏编辑文本,android,android-edittext,android-softkeyboard,window-soft-input-mode,Android,Android Edittext,Android Softkeyboard,Window Soft Input Mode,我的版面底部有一个EdiText。我遇到的问题是,当它聚焦时,屏幕会向上移动,给软键盘留出空间。为了解决这个问题,我添加了 android:windowSoftInputMode="adjustResize" 在我的活动声明中,在清单中。现在的问题是,编辑文本隐藏在软键盘后面,尽管屏幕不会移动。 如果我把 android:windowSoftInputMode="adjustPan" 然后活动的主窗口向上移动,这是我不希望看到的。 当EdiText获得焦点时,如何解决此问题?活动的主窗口不会

我的版面底部有一个
EdiText
。我遇到的问题是,当它聚焦时,屏幕会向上移动,给软键盘留出空间。为了解决这个问题,我添加了

android:windowSoftInputMode="adjustResize"
在我的
活动
声明中,在清单中。现在的问题是,编辑文本隐藏在软键盘后面,尽管屏幕不会移动。 如果我把

android:windowSoftInputMode="adjustPan"
然后活动的主窗口向上移动,这是我不希望看到的。 当
EdiText
获得焦点时,如何解决此问题?活动的主窗口不会向上移动,以便为软键盘腾出空间,但主窗口会调整大小,包括
EdiText
,以便键盘位于许多应用程序中看到的
EdiText
下方

布局

<?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:background="@color/background_feed">


    <ProgressBar
        android:id="@+id/progress"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_gravity="center_horizontal|center_vertical" />



    <ListView
        android:id="@+id/comments"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#F7F7F7"
        android:paddingTop="10dp"
        android:layout_above="@+id/border_view_comment"
        android:divider="@android:color/transparent"
        android:dividerHeight="10dp"
        android:paddingBottom="10dp"
        android:clipToPadding="false"
        android:scrollbarStyle="outsideOverlay" />

    <TextView
        android:id="@+id/empty_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="@string/no_comment_msg"
        android:visibility="gone"/>

    <View
        android:id="@+id/border_view_comment"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_above="@+id/commentlayout"
        android:background="#C7C7C7"
        android:visibility="gone"/>


    <RelativeLayout
        android:id="@+id/commentlayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@drawable/comment_box_shadow"
        android:padding="10dp">

        <ImageView
            android:id="@+id/commentor_image"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_marginRight="15dp"
            />

        <ImageView
            android:id="@+id/clickPostComment"
            android:layout_width="30dp"
            android:layout_height="45dp"
            android:layout_alignParentRight="true"
            android:src="@drawable/post"
            android:textColor="@color/white" />

        <EditText
            android:id="@+id/commentsPost"
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:layout_alignTop="@id/commentor_image"
            android:layout_marginRight="10dp"
            android:layout_toLeftOf="@id/clickPostComment"
            android:layout_toRightOf="@id/commentor_image"
            android:background="@drawable/comment_edittext_bg"
            android:hint="Comments"
            android:singleLine="true"
            android:maxLength="140"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:textColor="@color/title_gray"
            android:textColorHint="#d5d5d5"
            android:textSize="15sp" />

        <ImageView
            android:layout_width="25dp"
            android:layout_height="30dp"
            android:layout_alignTop="@id/commentsPost"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="-2dp"
            android:layout_toLeftOf="@id/commentsPost"
            android:scaleType="fitStart"
            android:src="@drawable/comment_shape" />
    </RelativeLayout>
</RelativeLayout>

通过将视图嵌入到
滚动视图中,使视图可滚动

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
   .....
    add your layout
   ......

</ScrollView>

.....
添加您的布局
......

如果这不能帮助您将根布局设置为
RelativeLayout
,并使用
RelativeLayout

设计布局如果我使用ScrollView,则我的整个布局设计将发生更改。最初,我的布局由列表组成,列表下方有一个注释框(edittext)…如果我将整个布局放在滚动视图中,那么我的编辑文本将移动到屏幕顶部,而我看不到列表..我已经在使用相对布局..我已经在讨论中发布了我的布局如何,这就是为什么使用滚动视图当键盘出现时,你看不到所有视图,所以你所能做的就是通过滚动隐藏其中一个视图,并且它是这样做的逻辑方法如果我使用scrollview,我只能看到edittext布局(
commentlayout
,如所述的xml),无论软键盘是隐藏的还是显示的,也在屏幕顶部。为什么会发生这种情况?尝试将其添加到scrollview android:fillViewport=“true”请使用scrollview发布您的xml