gpt4 book ai didi

android - xml中 fragment 中ListView上方的 float 操作按钮(FAB)?

转载 作者:数据小太阳 更新时间:2023-10-29 02:34:05 25 4
gpt4 key购买 nike

我使用了来自 here 的代码.就我而言,它看起来像

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.FragmentList"
android:orientation="vertical"
android:id="@+id/linear">

<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView" />

</LinearLayout>

<android.support.design.widget.CoordinatorLayout

android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add_white_24dp"
android:layout_gravity="bottom|end"
fab:elevation="6dp"
fab:pressedTranslationZ="12dp"
fab:backgroundTint="@color/accent"
app:layout_anchor="@id/listView"/>
</android.support.design.widget.CoordinatorLayout>

但我在 Android Studio 中有“多个根标签”。我做错了什么?请帮助我,我无法理解((

最佳答案

改为使用此布局:

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.FragmentList"
android:orientation="vertical"
android:id="@+id/linear">

<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView" />


<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add_white_24dp"
android:layout_gravity="bottom|end"
fab:elevation="6dp"
fab:pressedTranslationZ="12dp"
fab:backgroundTint="@color/accent"
app:layout_anchor="@id/listView"/>

</android.support.design.widget.CoordinatorLayout>

关于android - xml中 fragment 中ListView上方的 float 操作按钮(FAB)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36966674/

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