我想将工具栏的背景设置为透明。
-(void)displayTapped:(UIButton *)sender{
BOOL state = [[buttonStateArray objectAtIndex:sender.tag] boolValue];
[buttonStateArray replaceObjectAtIndex:sender.tag withObject:[NSNumber numberWithBool:!state]];
if(!state){
sender.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
}else {
sender.backgroundColor = [UIColor redColor];
}
这是我的工具栏布局背景不透明
只显示白色
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:elevation="4dp"
android:id="@+id/tool_bar_org"
android:paddingTop="0dp">
</android.support.v7.widget.Toolbar>
它不起作用。你能否告诉我如何让它变得透明。
答案 0 :(得分:0)
这是我在项目中使用的主题,使appCompact ActionBar变得透明,根据您的需要进行修改:
<style name="adhoctheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/adhocblack</item>
<item name="actionBarStyle">@style/adhocblack</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="windowActionBarOverlay">true</item>
</style>
<style name="adhocblack" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#0D000000</item>
<item name="background">@color/appcompact_transparent_actionbar_bg</item>
<item name="android:icon">@drawable/logo_header_2</item>
</style>
appcompact_transparent_actionbar_bg = #0D000000
查看here以查看不同值文件夹如何包含要在各种API上呈现的特定样式文件