Android版式:为什么我的按钮总是在ListView的下面?

米先生

这是我当前的LayOut代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:padding="16dp"
    android:background="@drawable/background"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageButton
        android:layout_above="@+id/list_of_messages"
        android:background="@android:color/transparent"
        android:id="@+id/buttonLogOut"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/button_log_out"
        android:paddingLeft="60dp" />
  <ImageButton
        android:background="@android:color/transparent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:src="@drawable/button_Send"
        android:id="@+id/fab"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true" />
    <EditText
        android:layout_toLeftOf="@+id/fab"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Your message"
        android:id="@+id/input" />
    <ListView
        android:background="@android:color/white"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:layout_above="@+id/fab"
        android:divider="@android:color/transparent"
        android:dividerHeight="16dp"
        android:id="@+id/list_of_messages"
        android:layout_marginBottom="16dp" />
</RelativeLayout>

这是它的样子:屏幕截图

“注销”按钮始终位于白色部分的下方。(我只用白色背景看一下,ListView覆盖了多少)。

因此-它始终覆盖顶部的所有内容。然而,带有发送按钮和布局底部的edittext的“上方”部分仍然有效。

我需要将按钮移到白色中间部分的顶部。为什么在地球上它不起作用?我通常会切换为线性布局,但是在此特定示例中,我无法做到这一点。在lin布局中,我只会添加权重10/80 /10。但是在这里它不起作用我在做什么错?:/

杰克杰伊

问题是您已经android:layout_alignParentTop="true"为自己设置ListView它,使其始终从顶部开始,这导致隐藏了注销按钮。

您应该进行两项更改才能获得所需的内容。

  1. android:layout_alignParentTop="true"从中删除ListView并将其添加到注销ImageButton

  2. android:layout_below="@+id/buttonLogOut"给你ListView

  3. android:layout_below="@+id/list_of_messages"从注销按钮中删除

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

你能告诉我为什么下面的 javascript 代码并不总是在下面的简单 index.html 中出现吗?

为什么我们总是在Android / Java中键入强制类型转换?

为什么我的ubuntu ip总是在变化?

为什么我的momentjs总是在03显示分钟?

为什么选项的位置总是在变化?

为什么我的球雪碧不总是在我的雪碧棒上反弹?

为什么我总是在 View.OnClickListener 中看到最后一个 id?

为什么“ _”不能总是在交互式shell中给我最后的结果

为什么我总是在mscor.lib中得到“ System.EntryPointNotFoundException”?

为什么我的任务总是在Windows 2008 Task Scheduler上运行

为什么我不能总是在Pidgin中要求重新授权?

为什么启动更新总是在我的计算机上失败?

为什么在我单击项目时,标题和图像总是在变化?

为什么我们不能总是在C中使用寄存器存储类?

为什么我总是在Codeigniter.2.1.2中得到表会话的重复值?

为什么我的服务器总是在文件夹权限中自动更改?

为什么我总是在 SparkJava 中获得一个新会话?

为什么我的段落总是放在我的按钮后面?

为什么总是在Android中启动JobService()中的onCreate()函数?

为什么Android总是在APK下载和安装中包含所有分辨率?

我应该总是在多线程编程中锁定全局数据吗,为什么或为什么不呢?

为什么总是在__new __()之后调用__init __()?

为什么总是在mouseDoubleClickEvent之前调用mousePressEvent

为什么 toString 总是在严格模式下运行?

为什么TODO总是在vim中突出显示?

为什么总是在JavaScript中声明函数?

为什么在If中总是在someArray中对someVar进行赋值

为什么构造函数总是在堆栈上调用?

为什么这个项目总是在Makefile中执行?