2015-03-19 94 views
-2

我正在製作一個新的應用程序與材料design.I有應用程序緊湊的庫,以支持預棒棒糖devices.I已顯示藍色color.The代碼工作良好的棒棒糖設備,但當我在棒棒糖設備上運行這個應用程序時,工具欄的顏色不會改變。風格不適用於棒棒糖設備

Style.Xml

<resources> 


    <style name="HsJobTheme" parent="CustomTheme"> 


    </style> 

    <style name="CustomTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    </style> 

    <style name="HsJobsToolBar" parent="ThemeOverlay.AppCompat.Light"> 

     <item name="android:windowBackground">@color/colorPrimary</item> 
     <item name="android:textColorPrimary">#fffffa12</item> 

    </style> 


</resources> 

Style.Xml(V21)

<resources> 

    <style name="HsJobTheme" parent="CustomTheme"> 
     <item name="android:colorPrimary">@color/colorPrimary</item> 
     <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item> 

    </style> 
</resources> 

toolbar.xml

<android.support.v7.widget.Toolbar 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/toolbar" 
    android:theme="@style/HsJobsToolBar" 
    xmlns:android="http://schemas.android.com/apk/res/android"></android.support.v7.widget.Toolbar> 

回答

-1

活動應該是這樣的

import android.os.Bundle; 
import android.support.v7.app.ActionBarActivity; 
import android.support.v7.widget.Toolbar; 
import android.view.Menu; 
import android.view.MenuItem; 


public class MainActivity extends ActionBarActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 
} 

toolbar.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="?attr/colorPrimary" 
    android:minHeight="?attr/actionBarSize" 
    android:theme="@style/HsJobsToolBar" /> 

</RelativeLayout> 

,並在實現工具欄是這樣的

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity"> 

    <include 
     layout="@layout/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

</RelativeLayout> 
+0

任何佈局我使用的動作條活動只,但仍它不預棒糖設備改變 – Anuj 2015-03-19 09:46:32

+0

您是否在'AndroidManifest'中擁有'android:theme =「@ style/CustomTheme」屬性? – momo 2015-03-19 10:14:01

+0

'android:theme =「@ style/HsJobTheme」' – momo 2015-03-19 10:20:39

相關問題