【问题标题】:fixed floating action button in fragment修复了片段中的浮动操作按钮
【发布时间】:2017-07-03 08:14:03
【问题描述】:

我有工厂,我想固定在 end|right|bottom 位置。 但在我的片段中,它使用滚动回收器隐藏和显示。 并且不显示片段中的所有工厂,因为我使用选项卡和工具栏。 请帮忙?

<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"
            tools:context="com.example.hadi.music.fragment.ListStoryFragment">

<android.support.v7.widget.RecyclerView
    android:id="@+id/rec_view_story"
    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:layout_alignParentBottom="true"
    android:layout_alignParentLeft="false"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="false"
    android:layout_gravity="bottom|end"
    android:layout_marginRight="20dp"
    android:layout_marginBottom="40dp"
    android:clickable="true"
    android:src="@drawable/icon_plus"
    app:fabSize="normal"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    />

【问题讨论】:

  • 这是你的全部布局代码吗?
  • 是的,这是我的布局

标签: android floating-action-button


【解决方案1】:

删除app:layout_behavior="@string/appbar_scrolling_view_behavior" android:layout_gravity="bottom|end"两行

【讨论】:

  • 不起作用它隐藏并在再次滚动时显示而不显示所有工厂
【解决方案2】:

试试这个xml

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

      <android.support.v7.widget.RecyclerView
          android:id="@+id/topic_list_recycler_view"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/add_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="16dp"
        android:src="@drawable/ic_add"
        app:fabSize="normal" />

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-15
    • 2017-10-21
    • 1970-01-01
    • 2015-06-25
    • 1970-01-01
    • 1970-01-01
    • 2019-02-04
    • 2016-08-26
    相关资源
    最近更新 更多