首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"adjustPan“不太好用

"adjustPan“不太好用
EN

Stack Overflow用户
提问于 2015-10-18 02:35:18
回答 2查看 1.1K关注 0票数 1

我正在创建android聊天应用程序。

然而,当键盘打开时,它很少覆盖EditText。

如果我使用"adjustResize“,它不会覆盖EditText,而是覆盖ListView。

清单:

android:windowSoftInputMode="stateAlwaysHidden|adjustPan“

布局:

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">


    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/lV_chat"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_above="@+id/linearLayout3"
        android:background="@color/gray"
        android:layout_below="@+id/toolbarChat"
        android:divider="@null"
        android:paddingRight="@dimen/space_6dp"
        android:paddingLeft="@dimen/space_6dp" />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="@dimen/chat_text_input_height"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:id="@+id/linearLayout3"
        android:background="@color/white">

        <EditText
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:inputType="textMultiLine"
            android:ems="10"
            android:id="@+id/eT_chat"
            android:layout_weight="1"
            android:background="@color/transparency"
            android:layout_marginLeft="@dimen/space_20dp"    
            android:textCursorDrawable="@null" />

        <ImageButton
            android:layout_width="@dimen/chat_send_button_width"
            android:layout_height="match_parent"
            android:id="@+id/iB_send"
            android:background="@color/light_blue"
            android:src="@drawable/ic_send"
            android:scaleType="centerInside" />
    </LinearLayout>

</RelativeLayout>

EN

回答 2

Stack Overflow用户

发布于 2015-10-18 03:45:26

试着做这样的事

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent" 
    >

    <RelativeLayout
        android:id="@+id/mainLayout"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="50dp"
        android:fitsSystemWindows="true">


        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/lV_chat"
            android:divider="@null"
             />



    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            >

        <EditText
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:inputType="textMultiLine"
            android:ems="10"
            android:id="@+id/eT_chat"
            android:layout_weight="1"
            android:textCursorDrawable="@null" />

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:id="@+id/iB_send"
            android:src="@mipmap/ic_launcher"
            android:scaleType="centerInside" />
    </LinearLayout>

</RelativeLayout>
    </RelativeLayout>

您可以让android:layout_marginBottom="your edittext's layout's width"到您的main layout,其中包含listview,然后它应该使用Relative layout和该Linear layout内部修复您的问题。

记住不要将这些行添加到您的linear layout

代码语言:javascript
复制
android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"

相对布局应该有android:layout_alignParentBottom="true",其中包含EditText和发送icon

票数 0
EN

Stack Overflow用户

发布于 2015-10-18 04:03:24

在我看来,"adjustResize“是您最好的选择,.This将调整列表视图的大小以适应键盘。您可以在列表中使用bottomPadding。"adjustPan“不会有太大的帮助,因为它会改变整个布局,而且看起来也不太好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33193725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档