Study/Java, Android

Android Theme.MaterialComponents의 button 문제

BlueBright 2019. 4. 10. 10:56

안드로이드 style에 Theme.MaterialComponents 와 관련된 theme을 적용하면

Button을 커스터마이징 하는데 문제가 생긴다.

(필자의 경우 drawable에 정의한 background를 적용하려고 했는데 듣지를 않았다...)

 

 

https://stackoverflow.com/a/52751122/7017299

 

when use Theme.MaterialComponents.Light.NoActionBar style, set button background not effect

In order to use Chip and ChipGroup , i set Application style extends "Theme.MaterialComponents.Light.NoActionBar" int manifests.xml, then i set Button "android:background" attr ,but it's not effec...

stackoverflow.com

 

https://stackoverflow.com/a/52673168/7017299

 

Can't use android:background with button from the new material components

I'm using the new material components com.google.android.material:material with android x but I can't set a custom background to the button. I know that I can use app:backgroundTint to change the ...

stackoverflow.com

 

두 글 모두 같은분이 답변을 ...

 

즉, 머티리얼 버튼의 경우 자체적으로 백그라운드를 가지고 있으니까,

안드로이드의 일반 버튼으로 변경한 후에 백그라운드를 적용하라고 한다.

(xml에 android.widget.Button 또는 androidx.appcompat.widget.AppCompatButton을 사용해라)

 

ps. 변경하니까 안드로이드 스튜디오의 xml preview 기능이 재작동을 했다.

 

style을 수정하라는 이야기도 있던 것 같은데, 적용이 잘 안됬던 것 같음...