gpt4 book ai didi

android - 在工具栏下方添加 fragment

转载 作者:行者123 更新时间:2023-11-29 15:45:15 25 4
gpt4 key购买 nike

我有一个 activity.xml

如您所见,这是一个相对布局。我希望包含 fragment 的框架布局将位于工具栏下方。

肯定会添加 fragment 。但它被添加在顶部,覆盖了工具栏。只是想知道我做错了什么。

网站出于某种原因不允许我添加代码。它告诉我它的格式不正确。这是 activity.xml 布局。

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

<!--scroll|snap-->
<android.support.v7.widget.Toolbar
android:id="@+id/appToolBar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolBarHeight"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

<FrameLayout
android:id="@android:id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/appToolBar"/>

</RelativeLayout>

这就是我在 Activity.java 文件中所做的。

getFragmentManager().beginTransaction().add(android.R.id.content, SetupFrag.createInstance(false), SETUP_FRAGMENT).commit();

最佳答案

您正在使用现有的 id,@android:id/content

您应该使用+ 添加您自己的ID,@+id/content,否则 fragment 将被添加到内容 View (您的 Activity 布局之上的级别).

关于android - 在工具栏下方添加 fragment ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33978452/

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