๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’š ๊ฐœ๋ฐœ/์•ˆ๋“œ๋กœ์ด๋“œ

[์•ˆ๋“œ๋กœ์ด๋“œ] ๋ฒ„ํŠผ ์ƒ‰๊น” ๋ฐ”๊พธ๊ธฐ

by devshin.kr 2021. 10. 28.
728x90
๋ฐ˜์‘ํ˜•

์ถ”๊ฐ€ : https://devshin93.tistory.com/112

ใ„ด ๊ณต๋ถ€ํ•˜๋ฉด์„œ ์•Œ๊ฒŒ ๋œ ๊ฒƒ. ์•„๋ž˜ ๋ณธ๋ฌธ์ฒ˜๋Ÿผ ํ•˜๋ฉด ์•ˆ๋“œ๋กœ์ด๋“œ์˜ ๊ธฐ๋ณธ ํ…Œ๋งˆ๊ฐ€ ๋ชจ์กฐ๋ฆฌ ๋ฐ”๋€Œ์–ด ๋ฒ„๋ ค ์ •์‹  ์—†๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.
๋”ฐ๋ผ์„œ 112๋ฒˆ ๊ฒŒ์‹œ๊ธ€์—์„œ ์†Œ๊ฐœํ•˜๋Š” ๊ธ€๋กœ ํ•˜๋Š” ๊ฒŒ ๋‚˜์„ ๊ฒƒ์ด๋‹ค. (2021.11.11.)

 

[ ์•ˆ๋“œ๋กœ์ด๋“œ] ๋ฒ„ํŠผ ๋ˆŒ๋ €์„ ๋•Œ ๋ฒ„ํŠผ ์ƒ‰๊น”๊ณผ ํ…์ŠคํŠธ ์ƒ‰๊น”์ด ๋ฐ”๋€Œ๊ฒŒ ํ•˜๊ธฐ. ๋ฒ„ํŠผ ์ปค์Šคํ…€! - selector, rip

์ด๋ ‡๊ฒŒ ๋˜๋Š” ๊ฒƒ์„ ๋งŒ๋“ค ๊ฒƒ์ด๋‹ค. ์กฐ๊ธˆ ๋ณต์žกํ•ด ๋ณด์ผ ์ˆ˜ ์žˆ๋Š”๋ฐ... ใ…Ž ์ฒœ์ฒœํžˆ ๋”ฐ๋ผ ์˜ค๋ฉด ์‰ฝ๋‹ค. ๋ณต์žกํ•˜๊ณ  ๋ชจ๋ฅด๊ฒ ์œผ๋ฉด ์ผ๋‹จ ๋ณต๋ถ™ํ•ด์„œ ๋„ฃ๊ณ  ๊ฐ’์„ ๋ฐ”๊ฟ” ๊ฐ€๋ฉด์„œ ํ™•์ธํ•ด ๋ณด์‹œ๊ธธ.. 0. MainActivity.java (ํŒจํ‚ค์ง€๋ช…

devshin93.tistory.com

 

 


1. Android ์—์„œ ๋ฒ„ํŠผ ์ƒ‰๊น” ๋“ฑ์„ ๋ฐ”๊พธ๊ณ  ์‹ถ์œผ๋ฉด res > values > themes.xml ์—์„œ parent="Theme.AppCompat" ์œผ๋กœ ๋ฐ”๊พธ์–ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค.
(์ฒ˜์Œ ์ƒ์„ฑํ•œ ๊ธฐ๋ณธ parent ๊ฐ’์€ "Theme.MaterialComponents.DayNight.DarkActionBar" ์ผ ๊ฒƒ..)

 

2. ๊ทธ ๋‹ค์Œ res > drawable ์—์„œ ์šฐํด๋ฆญ์„ ํ•ด New Drawable Recourse File ์„ ํด๋ฆญํ•ด btn_blue.xml ํŒŒ์ผ์„ ๋งŒ๋“ค์ž.
Root element ๋Š” shape ์œผ๋กœ ๋ณ€๊ฒฝ

 


3. btn_blue.xml ์ฝ”๋“œ ๋‚ด์šฉ

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding = "10dp">
    <!-- ๋ฒ„ํŠผ ์ƒ‰๊น” -->
    <solid android:color="#1473E6"/>
    <!-- ๋„ค ๊ท€ํ‰์ด? ๋ชจ์–‘ -->
    <corners
        android:bottomLeftRadius="5dp"
        android:bottomRightRadius="5dp"
        android:topLeftRadius="5dp"
        android:topRightRadius="5dp"/>
    <!-- ํ…Œ๋‘๋ฆฌ ์ƒ‰๊น” -->
    <stroke android:width="1dp"
        android:color="#BDBDBD"/>
</shape>

 



4. src > layout > ์‚ฌ์šฉํ•  activity.xml ์—์„œ Button ์„ ์‚ฌ์šฉํ•˜๋Š” ์ฝ”๋“œ. ์ค‘์š”ํ•œ ๊ฒƒ์€ android:background ์ด๋‹ค.

<Button
android:id="@+id/btn_exit"
android:layout_width="match_parent"
android:layout_height="38dp"
android:layout_marginStart="18.2dp"
android:layout_marginEnd="18.2dp"
android:layout_marginBottom="18.2dp"
android:background="@drawable/btn_blue"
android:text="@string/btn_success"/>




5. ๋ฐ”๋€ ๋ฒ„ํŠผ ์ƒ‰๊น”์„ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

 

>> ๋‹ค์Œ ์žฅ์—์„œ๋Š” themes.xml ์—์„œ parent="Theme.AppCompat" ์œผ๋กœ ๋ณ€๊ฒฝ ํ•จ์œผ๋กœ ์ธํ•ด ๋‹ค๋ฅธ ์ƒ‰์ด ๋ณด์ด์ง€ ์•Š๋Š” ๊ฒฝ์šฐ์— ๋Œ€ํ•ด ๋‹ค๋ฃฌ๋‹ค.

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€