2015-11-11 19 views
13

Próbuję zmienić kolor tła i kolor tytułu akcji, wypróbowałem oficjalny tutorial i kilka odpowiedzi stąd, ale żaden nie działał dla mnie, brakuje mi coś.Ustawienia paska narzędzi Android tła i kolorów tekstu w Androidzie Studio 1.4.1

styles.xml

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

styles.xml (v21)

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
    <item name="android:windowDrawsSystemBarBackgrounds">true</item> 
    <item name="android:statusBarColor">@android:color/transparent</item> 
</style> 

główną działalność:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
    android:layout_height="match_parent" android:fitsSystemWindows="true" 
    tools:context=".MainActivity"> 

    <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" 
     android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar android:id="@+id/toolbar" 
      android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

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

    <android.support.design.widget.FloatingActionButton android:id="@+id/fab" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" 
     android:src="@android:drawable/ic_dialog_email" /> 

</android.support.design.widget.CoordinatorLayout> 

Odpowiedz

40

Więc jeśli tak jak ja używasz Android 1.4.1 i Studio jesteś nowy w programowaniu w systemie Android, ustawienie tytułu i kolorów tła można wykonać w następujący sposób:

Tło: (sprawdź colors.xml z tym generowany kod BlanckActivity)

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <color name="colorPrimary">#3F51B5</color><!--Background color for AppBar--> 
    <color name="colorPrimaryDark">#303F9F</color><!--i ignore its use--> 
    <color name="colorAccent">#FF4081</color><!--color effects, EditText, RadioButtons...--> 
</resources> 

Tytuł, napisów i menu podręczne i jego elementy (sprawdź "styles.xml"):

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"> 
     <item name="android:textColorPrimary">TITLE_COLOR_GOES_HERE</item> 
     <item name="android:textColorSecondary">SUBTITLE_COLOR_GOES_HERE</item> 
</style> 
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"> 
     <item name="android:colorBackground">MENU_POPUP_BACK_COLOR</item> 
     <item name="android:textColor">@color/MENU_POPUP_ITEMS_COLOR</item> 
</style> 

Main Colors for an Activity

Mam nadzieję, że pomoże to komuś, kto mnie polubi, jest zdezorientowany w pierwszych krokach z oficjalnymi samouczkami na temat Androida.

+0

Dzięki za pomoc! – LipeTuga

Powiązane problemy