[英]how to set image to background n text color of action bar?
我想將backgroung圖像也設置為主要活動和所有活動的動作欄,並且還想更改動作欄文字的文本顏色,我嘗試了此代碼,但它給我錯誤plz幫助我
style.xml
<resources>
<!-- Base application theme. -->
<style name="AppThe" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="ActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@drawable/actionbar_background</item>
</style>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBar</item>
</style>
</resources>`
清單代碼
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hp.navigationd"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="OLXA"
android:theme="@style/AppThe" >
<activity
android:name="com.example.hp.navigationd.MainActivity"
android:label="OLXA" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.hp.navigationd.post_ad"
android:label="@string/Ad_Details"
android:parentActivityName="com.example.hp.navigationd.MainActivity" />
<activity android:name="com.example.hp.navigationd.My_account" />
<activity android:name="com.example.hp.navigationd.My_fav" />
<activity android:name="com.example.hp.navigationd.My_ads" />
<activity android:name="com.example.hp.navigationd.My_chats" />
<activity android:name="com.example.hp.navigationd.Rules" />
<activity android:name="com.example.hp.navigationd.Help" />
<activity android:name="com.example.hp.navigationd.About_us" />
</application>
</manifest>
嘗試這個,
安裝了,
<style name="AppThe" parent="Theme.AppCompat.Light.DarkActionBar">
用這個,
<style name="AppThe" parent="@android:style/Theme.Holo.Light.DarkActionBar">
查看以下樣式。
<style name="AppThe" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">@style/ActionBar</item>
<item name="actionBarStyle">@style/ActionBar</item>
</style>
<style name="ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/actionbar_background</item>
<item name="background">@drawable/actionbar_background</item>
</style>
在這里,您需要同時使用android:actionBarStyle and actionBarStyle
以及android:background and background
項目。 前者適用於原生支持ActionBar的較新版本的android。 后者適用於較早的android版本。
關於錯誤:
您不能在AppCompatActivity
使用"@android:style/Theme.Holo.Light"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.