drawable 폴더 > button_button01.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
 
    <item>
        <layer-list>
            <!-- shadow (밑으로) : 그림자 -->
            <item android:top="3dp">
                <shape>
                    <corners android:radius="3dp" />
                    <solid android:color="#1f000000" />
                </shape>
            </item>
            <!-- background (위로) -->
            <item android:bottom="3dp">
                <shape>
                    <corners android:radius="3dp" /
                    <solid android:color="#00854a" />
                    <stroke android:width="1dp" android:color="#6a6a6a" />
                </shape>
            </item>
        </layer-list>
    </item>
</selector>
 
cs

버튼을 커스텀 한다

<layer-list>태그 밑에 <item>태그 2개를 넣어서 하나는 버튼의 배경과 테두리를 다른하나는 그림자를 만든다



커스텀하고자 하는 버튼의 background 속성에 사용

1
2
3
4
5
6
7
8
9
10
    <!-- 버튼 -->
    <Button
        android:text="버튼"
        android:textColor="#fff"
        android:textSize="16dp"
        android:background="@drawable/button_button1"
        android:layout_gravity="center_vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <!-- //버튼 -->
cs





결과




+ Recent posts