# Android themes 定義button style ## Android studio 不知哪個版本開始就都引用的Material Design的樣板 ### 需求: 定義按鈕的風格 ### 作法: 在themes.xml新增 ```kotlin= <style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <item name="materialButtonStyle">@style/MyButton</item> </style> <style name="MyButton" parent="@style/Widget.MaterialComponents.Button"> <item name="backgroundTint">@color/teal_700</item> </style> ``` ### 重點: 以往的版本,參考程式碼第二行 name="materialButtonStyle" ,以往是寫成 name="buttonStyle", 因為現在都自動套用Material Design樣板,所以在這裡需要注意。 ###### tags: `themes` `kotlin` `Android`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up