gpt4 book ai didi

android - ListView 隐藏在 ToolBar 后面,Floating action button 隐藏在 ListView 后面

转载 作者:太空宇宙 更新时间:2023-11-03 10:37:39 28 4
gpt4 key购买 nike

我的 FAB 将显示在 android studio 的设计窗口中,但在我实际运行应用程序时不会显示。

此外,我有一个 ListView 项目,我指定它应该位于工具栏下方,但当我运行该应用程序时,它部分隐藏在工具栏后面。

<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/my_toolbar" />

<at.markushi.ui.CircleButton
android:layout_width="64dp"
android:layout_height="64dp"
app:cb_color="@color/colorPrimary"
app:cb_pressedRingWidth="8dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="openEditorForNewNote"
android:src="@drawable/ic_action_add"/>

</RelativeLayout>

how the layout appears in design mode

how app appears when run

做什么?

最佳答案

My FAB will shows up in the design window in android studio but does not show up when I actually run the app.

尝试在代码中将 FAB 移动到 ListView 之上,如下所示:

<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<at.markushi.ui.CircleButton
android:layout_width="64dp"
android:layout_height="64dp"
app:cb_color="@color/colorPrimary"
app:cb_pressedRingWidth="8dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="openEditorForNewNote"
android:src="@drawable/ic_action_add"/>

<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/my_toolbar" />
</RelativeLayout>

基本上,Android 根据它们在 XML 标记中的顺序以特定顺序呈现布局。

In addition, I have a ListView item which I have specified should sit below the toolbar, yet when I run the app it is partially hidden behind the toolbar.

将listView的高度改为wrap_content(我在上面的代码中也是这样改的,但这里又是这样):

<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/my_toolbar" />

因为 ListView 是工具栏的兄弟,当高度设置为 match_parent 时,它会填满整个屏幕,包括工具栏下方的区域。

关于android - ListView 隐藏在 ToolBar 后面,Floating action button 隐藏在 ListView 后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40643105/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com