2013-11-20 25 views
0

定義主題,我試圖在清單在Android應用

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 

,並添加風格

<resources> 

    <!-- 
     Base application theme, dependent on API level. This theme is replaced 
     by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
    --> 
    <style name="AppBaseTheme" parent="android:style/Theme.Holo.Light"> 
     <!-- 
      Theme customizations available in newer API levels can go in 
      res/values-vXX/styles.xml, while customizations related to 
      backward-compatibility can go here. 
     --> 
    </style> 

    <!-- Application theme. --> 
    <style name="AppTheme" parent="AppBaseTheme"> 
     <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
    </style> 
</resources> 

不管我做什麼,我總是有黑色行動酒吧並沒有什麼變化?我想申請Holo Light主題...

任何建議?

回答

1

如果你想使用的主題在你的整個應用程序,試試這個:

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.Holo.Light" > 
+0

已經嘗試過... <活動 機器人:名字= 「***」 機器人:標籤=「@字符串/ app_name「 android:theme =」@ android:style/Theme.Light「> –

+0

您是否爲自己的活動定義了佈局? – kai

2

創建自定義主題。

首先,在值增加的themes.xml這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="MyAppTheme" parent="@android:style/Theme.Light.NoTitleBar"> 
    <!-- Any customizations for your app running on pre-3.0 devices here --> 
    </style> 
</resources> 

然後,創建於res目錄名稱「值-V11」(Android 3.0以上版本)的目錄,並把一個主題。這樣

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="MyAppTheme" parent="@android:style/Theme.Holo.Light"> 
    <!-- Any customizations for your app running on 3.0+ devices here --> 
    </style> 
</resources> 

最後的XML,創建一個目錄,在res目錄名稱 「值-V14」(Android 4.0以上版本),並創建一個的themes.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="MyAppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar"> 
    <!-- Any customizations for your app running on 4.0+ devices here --> 
    </style> 
</resources> 

的manifest.xml

<application 
    ... 
    android:theme="@style/MyAppTheme"> 

</application> 

OR 創建自定義操作欄

actionbar_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    style="@style/ActionBarCompat" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingLeft="15dip" 
     android:paddingTop="15dip" 
     android:scaleType="center" 
     android:textColor="#ffffff" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     android:text="NAME" /> 

</LinearLayout> 

在你的佈局文件。 main_activity.xml

<include layout="@layout/actionbar_layout"/> 

中值 - > styles.xml

<style name="ActionBarCompat"> 
    <item name="android:layout_width">fill_parent</item> 
    <item name="android:layout_height">50dp</item> 
    <item name="android:orientation">horizontal</item> 
    <item name="android:background">@drawable/actionbar_background</item> 
</style>