【问题标题】:How to remove Floating Action Button from auto generated Scrolling Activity如何从自动生成的滚动活动中删除浮动操作按钮
【发布时间】:2017-05-20 17:50:52
【问题描述】:

我在 Android Studio 中创建了一个滚动活动,并从设置 FAB 操作的活动中删除了代码,但活动 xml 中没有匹配的属性:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="myactivity"
tools:showIn="@layout/activity_edit_address">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/text_margin"
    android:text="@string/large_text" />

</android.support.v4.widget.NestedScrollView>

我在 Google 上找到的所有内容都说要删除 FAB XML 属性以阻止它出现,但这似乎已经过时,因为它不存在。我在哪里可以删除这个?谢谢。

【问题讨论】:

    标签: java android xml android-studio


    【解决方案1】:

    当您生成 Scrolling Activity 时,它将生成 2 个名为 activity_scrolling.xmlcontent_scrolling.xml 的 xml 文件。只需从 activity_scrolling.xml 文件中删除 FAB 块即可。

    删除此块:

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        app:layout_anchor="@id/app_bar"
        app:layout_anchorGravity="bottom|end"
        app:srcCompat="@android:drawable/ic_dialog_email" />
    

    【讨论】:

    • 谢谢,不知道我是怎么错过的。允许时将接受作为答案。
    【解决方案2】:

    右键单击layout文件夹,然后单击在路径中查找

    搜索浮动

    从那里删除块然后Ctrl + Enter

    View image

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-21
      • 1970-01-01
      • 2015-11-19
      • 2021-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多