这是我当前的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
它,使其始终从顶部开始,这导致隐藏了注销按钮。
您应该进行两项更改才能获得所需的内容。
android:layout_alignParentTop="true"
从中删除ListView
并将其添加到注销ImageButton
。
加android:layout_below="@+id/buttonLogOut"
给你ListView
。
android:layout_below="@+id/list_of_messages"
从注销按钮中删除。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句