如何使支撑工具栏背景透明? [英] How to make the support Toolbar background transparent?

查看:163
本文介绍了如何使支撑工具栏背景透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,使新的Andr​​oid支持工具栏:

Is there a way to make the new Android support Toolbar:

android.support.v7.widget.Toolbar

有一个透明的背景是什么?

Have a transparent background?

我试过 colorPrimary 设置为一个ARGB(#00FFFFFF),但它只是给了我一个坚实的灰色条。而工具栏只允许我设置背景绘制。它是犹太设置背景绘制一个透明的PNG,或是否有更好的方法来做到这一点?

I tried setting the colorPrimary to an ARGB (#00ffffff) but it just gives me a solid gray bar. And Toolbar only allows me to set a background drawable. Is it kosher to set the background drawable to a transparent PNG, or is there a better way to do this?

在理想情况下,我会能够做到这一点在code /动画这让某些活动有一个透明的酒吧和一些活动则没有。

Ideally I'd be able to do it in code / animate it so certain activities have a transparent bar and some activities don't.

在此先感谢。

推荐答案

您可以将背景设置为Android的默认透明色,它工作得很好。此添加到您想要的布局透明工具栏

You can either set the background to android's default transparent color, which works just fine. Add this to the layout you want a transparent Toolbar:

安卓背景=@机器人:彩色/透明

如果你想以编程方式改变α,可以通过修改的工具栏背景本身的alpha做到这一点。刚刚获得绘制对象的实例,并设置alpha有:

If you want to change the alpha programmatically, you can do it by modifying the alpha on the Toolbar background itself. Just get an instance of the Drawable and set the alpha there:

mToolbar = findViewById(R.id.my_toolbar);
mToolbar.getBackground().setAlpha(0);

这篇关于如何使支撑工具栏背景透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆