首页 \ 问答 \ 带BottomNavigationView的FloatingActionButton(FloatingActionButton with BottomNavigationView)

带BottomNavigationView的FloatingActionButton(FloatingActionButton with BottomNavigationView)

我无法定位我的FAB。 它应该在右下方,但是在BottonNavigationView之上。

1)我可以实现这个没有RelativeLayout内coordinateLayout?

2)告诉我如何

3)我应该使用FrameLayout作为碎片的容器吗?

<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/appbar_padding_top"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay">

    </android.support.v7.widget.Toolbar>

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

<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

</FrameLayout>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_electricity"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="@dimen/fab_margin"
    app:layout_anchorGravity="bottom|right|end"
    app:srcCompat="@drawable/ic_add_electro" />

<android.support.design.widget.BottomNavigationView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom">

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

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

结果


I cant position my FAB. It should be bottom right, but on top of the BottonNavigationView.

1) Can i achieve this without RelativeLayout inside coordinateLayout?

2) Show me how

3) Should i use FrameLayout as a container for fragments?

<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/appbar_padding_top"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay">

    </android.support.v7.widget.Toolbar>

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

<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

</FrameLayout>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_electricity"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="@dimen/fab_margin"
    app:layout_anchorGravity="bottom|right|end"
    app:srcCompat="@drawable/ic_add_electro" />

<android.support.design.widget.BottomNavigationView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom">

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

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

result


原文:https://stackoverflow.com/questions/43128947
更新时间:2023-12-13 15:12

最满意答案

最好不要使用ifelse因为'Date'可以强制转换为integer存储值,而是将( := )'Start'指定为'SellDate',然后在'i'中指定逻辑条件以识别' “开始”中的NA'元素或“数字”中的1,并指定( := )'BuyDate'中与'i'对应'Start'的元素

data[, Start := SellDate][Number==1, Start := BuyDate
          ][is.na(Start), Start := BuyDate][]

正如@Cath在评论中提到的,这可以分两步完成

data[, Start := SellDate][(Number==1) | is.na(Start), Start := BuyDate][]

It is better not to use ifelse as the 'Date' can get coerced to integer storage values, instead, we assign (:=) 'Start' as the 'SellDate', then specify the logical condition in 'i' for identifying the 'NA' elements in 'Start' or the 1 in 'Number' and assign (:=) the elements in 'BuyDate' that correspond to 'i' to 'Start'

data[, Start := SellDate][Number==1, Start := BuyDate
          ][is.na(Start), Start := BuyDate][]

As @Cath mentioned in the comments, this can be done in two steps

data[, Start := SellDate][(Number==1) | is.na(Start), Start := BuyDate][]

相关问答

更多
  • 您第一次尝试失败的原因是,只有其中一个事件实际发生时, time[event==2]或time[event==3]评估为numeric(0) 。 DT[id=='A', time[event==2]] ## numeric(0) 解决这个问题的最简单方法是取两次的最大值: time <= max(time[event %in% 2:3]) DT[, state := ifelse(time >= time[event==1] & time <= max(time[event %in% 2:3]), 1, ...
  • 最快的方法可能取决于你的数据是什么样子。 这些例子中提到的那些都是可比的: ( twice被@DavidArenburg提及; onceadd被@akrun加入,我不确定如何用replications > 1来对这些进行基准测试,因为对象在基准测试期间实际上被修改了。) DT <- data.table(x=sample(c(NA,"",letters),1e8,replace=TRUE)) DT0 <- copy(DT) DT1 <- copy(DT) DT2 <- copy(DT) DT3 <- co ...
  • 你已经走了一个兔子洞。 这是上升的方式: DT[, col5:= shift(col3, fill = -1) == 0 & col3 != 0] # or DT[, col5:= shift(col3, fill = -1) == 0 & col3 != 0, keyby = key(DT)] You've gone down a rabbit hole. Here's the way up: DT[, col5:= shift(col3, fill = -1) == 0 & col3 != 0] ...
  • 最好不要使用ifelse因为'Date'可以强制转换为integer存储值,而是将( := )'Start'指定为'SellDate',然后在'i'中指定逻辑条件以识别' “开始”中的NA'元素或“数字”中的1,并指定( := )'BuyDate'中与'i'对应'Start'的元素 data[, Start := SellDate][Number==1, Start := BuyDate ][is.na(Start), Start := BuyDate][] 正如@Cath在评论中提到 ...
  • 我们可以在data.table使用Map和max.col来完成此操作 TDT[, compare := {d1 <- as.data.table(Map(function(x) x1 < x, .SD)) max.col(d1, "first") *(c(5, 1)[((Reduce(`+`, d1)!=0)+1)])}, .SDcols = x2:x5] #OP's code v1 <- TDT[, ifelse(x1 < x2,1,ifelse(x1 < x3,2,ifelse(x1 < ...
  • 使用data.table ,我们可以使用:= ,这将更有效(来自@ plafort帖子的示例数据) library(data.table)#v1.9.4+ setDT(df)[X5==0, X6:=1] Usingdata.table, we can use :=, which would be more efficient (example data from @plafort's post) library(data.table)#v1.9.4+ setDT(df)[X5==0, X6:=1]
  • 您可以使用联接: # initialize to zero log[, correct := 0L ] # update to 1 if matched log[question_table, on=c(question_id = "id", student_answer = "correct_ans"), correct := 1L ] student question_id student_answer correct 1: b 1 ...
  • 这是一种方法,如果列的所有值都是NA ,则给你-Inf (和警告)(如果你愿意,你可以稍后用NA替换它): DT[, lapply(.SD, function(x) max(v[!is.na(x)]))] # x y z v # 1: 6 9 -Inf 9 正如@DavidArenburg所建议的那样,为了确保一切顺利,即使所有值都是NA (没有警告并且直接NA为结果),您可以: DT[, lapply(.SD, function(x) { temp <- v[!is.na(x)] ...
  • 好吧,你可以把你喜欢的订单放在某个地方: levelmap = data.table(Level = 1:2, ord = list( c("Conference", "Webinar", "Meeting", "Video"), c("Webinar", "Meeting", "Conference", "Video") )) 然后使用您之前的方法: DT[, r := .I] for (ii in seq(nrow(levelmap))) DT[ Level == level ...
  • 根据你的描述,你想检查非列的数量,然后根据这个结果做一些事情(为什么你需要“if”/“ifelse”语句)。 所以,你可以像下面那样实现,并在特定函数中编写内部循环。 yourFunc <- function(x, data) { # do what your want / your loops on "data" # sample, you can check the result in here if(x > 1) 1 else 0 } m = matrix(c(1,2,NA,N ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)