android - 最后一个单元格在自定义 Android ListView 布局中不可见

标签 android android-layout android-listview

我有一个自定义的ListView +(发送消息的控件)布局,用于发送消息和显示聊天。问题是 ListView 的最后一个单元格不完全可见(它就像在用于写入和发送消息的蓝色控件后面):

enter image description here

我已经将以下内容添加到我的 Manifest 文件中:

android:windowSoftInputMode="stateVisible|adjustResize"

这是我的 xml 布局文件:

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

    <ListView
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <RelativeLayout
        android:id="@+id/footer_layout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:background="@color/color_custom_light_blue"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/editText"
            android:layout_width="250dp"
            android:layout_height="match_parent"
            android:layout_centerVertical="true"
            android:layout_margin="3dp"
            android:background="@drawable/rounded_edittext"
            android:hint="@string/message_list_edittext_hint"
            android:lines="2"
            android:padding="5dp"
            android:textSize="17sp"
            android:textStyle="normal" />

        <ImageButton
            android:id="@+id/clearButton"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:layout_centerVertical="true"
            android:layout_gravity="right|center_vertical"
            android:layout_margin="3dp"
            android:layout_toRightOf="@id/editText"
            android:background="@drawable/clear_button_selector"
            android:contentDescription="@string/clear_button_content_description"
            android:onClick="clearLetterClicked" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_centerVertical="true"
            android:layout_margin="3dp"
            android:layout_toRightOf="@id/clearButton"
            android:onClick="sendClicked"
            android:text="@string/message_list_edittext_send"
            android:textColor="@color/white"
            android:textSize="17sp" />
    </RelativeLayout>

</RelativeLayout>

因此,我希望当我滚动到带有聊天消息的 ListView 末尾时,最后一个单元格变得可见。

最佳答案

您应该在页脚布局之后定义您的ListView。
该容器是一个RelativeLayout,因此您可以将ListVew设置为ABOVE页脚布局。
还将其高度设置为FILL_PARENT
所以,它不会被它覆盖。它会在页脚开始之前停止增长。
轻松修复,发挥技巧。

关于android - 最后一个单元格在自定义 Android ListView 布局中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21098342/

相关文章:

android - 打开抽屉导航时框架布局消失

java - 从自定义函数读取文件是 FC 应用程序

android - 如何在带有 React Native Text 的 Android 中实现软连字符

android - recycleview 上的 wrap_content,获取项目的高度(水平列表)

android - 位图在Android中是如何存储在内存中的?

android - 如何在 android 中获得最大 X 和最大 Y 点?

android - 选择 ListView 项时更改 TextView 的字体颜色

android - ListView setOnItemClickListener 在自定义 ListView 中不起作用

android - 以编程方式更改 CardView 的背景颜色

android - 屏幕中央的TextView