簡體   English   中英

Android-將背景應用於操作欄

[英]Android - Apply background to the action bar

我正在遵循“設置操作欄樣式”教程: http : //developer.android.com/training/basics/actionbar/styling.html

我在@ drawable / actionbar_background上收到“無法解析符號”和錯誤

據我了解,我在drawable下沒有“ actionbar_background”。 我不明白什么是“ actionbar_background”。

這是來自res / value / themes.xml上的示例代碼的一部分

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme"
           parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

   <!-- ActionBar styles -->
    <style name="MyActionBar"
           parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/actionbar_background</item>
    </style>
</resources>

據我了解,我在drawable下沒有“ actionbar_background”。 我不明白什么是“ actionbar_background”。

它是存儲在res/drawable-*文件夾中的資源文件, xmlpng

嘗試創建一個名為actionbar_background.xml的xml文件,並將其存儲在res/drawable並包含以下內容:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
     android:shape="rectangle" android:padding="10dp">
    <solid android:color="#FFFF00"/>
</shape>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM