styles.xml
<resources>
<style name="CustomTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/CustomBar</item>
<item name="actionBarStyle">@style/CustomBar</item>
</style>
<style name="CustomBar" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">@color/black</item>
<item name="android:src">@drawable/home</item>
<item name="background">@color/black</item>
<item name="src">@drawable/home</item>
</style>
</resources>
上面的代码不起作用,因为找不到android:src
,但我希望达到预期的效果。
我有一个公司徽标,我想用作动作栏主图像,但不想使用静态图像进行全背景着色。徽标图片@drawable/home
具有透明背景。
如何设置操作栏的样式以包含图像和背景颜色?
答案 0 :(得分:0)
我不知道我们有src,这是代码对我有用: 设置图像这是我使用的:
<item name="android:background">@drawable/headerflowerimage</item>
请在此处找到完整的代码:
<!-- the theme applied to the application or activity -->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/SActionBar</item>
<!--- Support library compatibility-->
<item name="actionBarStyle">@style/SActionBar</item>
<item name="android:actionBarTabStyle">@style/STabBars</item>
<!-- Support library compatibility -->
<item name="actionBarTabStyle">@style/STabBars</item>
</style>
<!-- ActionBar tabs styles -->
<style name="STabBars" parent="@style/Widget.AppCompat.ActionBar.TabView">
<!-- tab indicator -->
<item name="android:background">@color/tabbar_background</item>
<item name="android:backgroundStacked">@color/background_material_light</item>
<item name="android:actionBarTabTextStyle">@color/greyrish_s</item>
<!-- Support library compatibility -->
<item name="background">@color/tabbar_background</item>
<item name="backgroundStacked">@color/background_material_light</item>
<item name="actionBarTabTextStyle">@color/greyrish_s</item>
</style>
<!-- ActionBar styles -->
<style name="SActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/headerflowerimage</item>
<item name="android:titleTextStyle">@style/sTitleColor</item>
<item name="android:displayOptions">showTitle</item>
<!-- Support library compatibility -->
<item name="background">@drawable/headerflowerimage</item>
<item name="titleTextStyle">@style/sTitleColor</item>
<item name="displayOptions">showTitle</item>
</style>