2015-10-04 13 views
9

Mój kod to:Zmiana Pasek motyw programowo

<android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="?attr/colorPrimary" 
     android:minHeight="?attr/actionBarSize" 
     app:theme="@style/Toolbar_Theme"/> 

Chcę zmienić app: motyw w kodzie Java. Czy mogę znaleźć dowolną metodę jako toolbar.setTheme, która służy do zmiany stylu paska narzędzi?

+2

można zmienić tylko kolor tła i kolor tytuł używając kodu: toolbar.setBackgroundColor (newColor); toolbar.setTitleTextColor (titleColor); – Lazai

+0

@Lazai dziękuję –

+0

Wypróbuj to: https://stackoverflow.com/questions/31225189/how-to-change-appcompat-v21-toolbar-theme-programically –

Odpowiedz

0

Można go zmienić programowo tak:

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

toolbar.getContext().setTheme(R.style.ThemeOverlay_AppCompat_Dark_ActionBar); 
Powiązane problemy