android app 层叠加,android – 无法让AppCompat ActionBar / Toolbar成为叠加层

所以,我有一个工具栏,我将其设置为supportActionBar,我希望它处于叠加模式.在这一点上,我觉得我已经尝试了一切,但似乎没有任何工作.

这是我目前的风格:

@color/primary

@color/accent

@style/Widget.IconPageIndicator

@style/Widget.TabPageIndicator

false

true

true

@color/background

true

true

这是我的工具栏的代码:

android:id="@+id/actionbar"

android:layout_height="wrap_content"

android:layout_width="match_parent"

android:minHeight="?attr/actionBarSize"

android:background="?attr/colorPrimary"

app:theme="@style/CustomActionBar"/>

最后,这是我在Activity中设置它的地方:

actionbar = (Toolbar) findViewById(R.id.actionbar);;

setSupportActionBar(actionbar);

我也试过调用getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY)没有运气.

解决方法:

所以,事实证明这个问题同时非常简单,但并不明显(对我来说,至少).基本上问题是尽管工具栏被设置为Actionbar,但它仍然是在一天结束时用XML声明的布局元素.因此,诀窍当然是确保它与XML重叠.这是我的布局中的一个示例,现在:

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:id="@+id/actionbar"

android:layout_height="wrap_content"

android:layout_width="match_parent"

android:minHeight="?attr/actionBarSize"

android:background="?attr/colorPrimary"/>

android:id="@+id/container"

android:layout_width="match_parent"

android:layout_height="match_parent" />

一切都按预期工作了.希望如果他们遇到同样的问题,这可以帮助别人!

标签:android,appcompat

来源: https://codeday.me/bug/20190609/1206734.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值