Tiripia Diary

안드로이드 스튜디오 버튼 클릭 시 변경 활성화 비활성화 방법

안드로이드 스튜디오 버튼 클릭 시 변경 활성화 비활성화 방법

안드로이드 스튜디오 버튼 클릭을 하면 버튼을 비활성화 시키는 경우가 있습니다.

JAVA에서 비활성화 시키면 버튼이 클릭이 되지 않는데요.

사용자 편의를 위해서 버튼이 비활성화 되었다고 디자인 해주는 것도 좋은 방법입니다.

drawable\select_bottom.xlm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version=“1.0” encoding=“utf-8”?>
<selector xmlns:android=“http://schemas.android.com/apk/res/android”>
 
    <item android:state_enabled=“true”>
        <shape android:shape=“rectangle”>
            <solid android:color=“#2962FF” />
            <stroke android:width=“2dp” android:color=“#FF6200EE” />
        </shape>
    </item>
 
    <item android:state_enabled=“false”>
        <shape android:shape=“rectangle”>
            <solid android:color=“#304FFE” />
            <stroke android:width=“2dp” android:color=“#000000” />
        </shape>
    </item>
 
</selector>
cs

activate_main.xlm

1
2
3
4
5
6
7
8
9
10
11
 <Button
android:background=“@drawable/selector_button”                              
android:layout_marginTop=“15dp”
android:id=“@+id/btn”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_weight=“1”
android:fontFamily=“@font/nanumgothicexbold”
android:text=“text”
android:textColor=“@color/white” />    
cs

이렇게 하면 안드로이드 스튜디오 버튼 클릭 시 변경 활성화 비활성화 됩니다.

Exit mobile version