Android

์•ˆ๋“œ๋กœ์ด๋“œ ๋ฒ„ํŠผ background drawable ์ ์šฉ ์•ˆ๋จ. ์•ˆ๋˜๋Š” ์ด์œ 

๋…ธ๋ฃจ๋ฃฝ 2021. 9. 8. 18:49

์•ˆ๋“œ๋กœ์ด๋“œ ๋ฒ„ํŠผ background drawable ์ ์šฉ ์•ˆ๋จ

์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ ๋ฒ„ํŠผ์„ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•ํ•˜๊ธฐ ์œ„ํ•ด ์—ด์‹ฌํžˆ drawable๋กœ shape๋ฅผ ๋งŒ๋“ค์—ˆ๋Š”๋ฐ

background์— ์ ์šฉ์‹œํ‚ค๋ฉด ๋””ํดํŠธ ์ƒ‰์ธ ๋ณด๋ผ์ƒ‰์ด ๋œจ๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค.

 

drawable/buttom_background.xml ํŒŒ์ผ

 

Whyrano . . .

Button ์„

android.widget.Button ๋˜๋Š” androidx.appcompat.widget.AppCompatButton ์œผ๋กœ ๋ฐ”๊ฟ”์ฃผ๋ฉด ๋ฐ”๋กœ ํ•ด๊ฒฐ๋œ๋‹ค.

 

ํ•˜์ง€๋งŒ ์™œ ์ด๋Ÿฐ ๊ฑด์ง€, ๊ทธ๋ƒฅ Button๊ณผ๋Š” ๋ฌด์Šจ ์ฐจ์ด์ ์ด ์žˆ๋Š”์ง€ ๊ถ๊ธˆํ•ด์„œ ์ด์œ ๋ฅผ ์ฐพ์•„๋ณด์•˜๋‹ค.

 

 

์•ˆ๋“œ๋กœ์ด๋“œ ๋ฒ„ํŠผ background drawable ์ ์šฉ ์•ˆ ๋˜๋Š” ์ด์œ 

res/values/themes/themes.xml ๋กœ ๊ฐ€๋ณด๋ฉด ์ด์œ ๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

 

๋ฐ”๋กœ ์ด ๋ถ€๋ถ„ ๋•Œ๋ฌธ์ด๋‹ค.

 

MaterialComponents ๋””์ž์ธ์„ ์ƒ์†๋ฐ›๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

MaterialComponents ๋””์ž์ธ์€ ์•„์˜ˆ Background๋ฅผ ์ž์ฒด์ ์œผ๋กœ ๊ฐ–๊ณ  ์žˆ์–ด์„œ ๋ณ€๊ฒฝ๋˜์ง€ ์•Š๋Š”๋‹ค๊ณ  ํ•œ๋‹ค.

๋”ฐ๋ผ์„œ ์•„์˜ˆ ์ด ๋ถ€๋ถ„์„

parent='Theme.AppCompat.Light' ๋กœ ๋ฐ”๊ฟ”์ฃผ๊ธฐ๋งŒ ํ•ด๋„ ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋˜๊ธด ํ•œ๋‹ค.

ํ•˜์ง€๋งŒ ํ•ด๋‹น style์„ ์ ์šฉํ•˜๊ณ  ์žˆ๋Š” Activity๋‚˜ ํ”„๋กœ์ ํŠธ ์ „์ฒด์˜ theme์ด ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ์œผ๋‹ˆ ์ฃผ์˜๋ฐ”๋žŒ!

 

์ฐธ๊ณ 

https://stackoverflow.com/questions/52743190/when-using-theme-materialcomponents-light-noactionbar-style-setting-button-back/52751122

https://velmurugan-murugesan.medium.com/material-button-in-android-e4391a243b17