헐 이렇게 쉽게 커스텀 버튼이 가능하다니....
Drawable.에서 xml 파일 하나 만들어서 Button 사용하는 레이아웃에서 backgournd로 지정하면 끝난다.
Drawable
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/mach_selection_menu_default_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/mach_selection_menu_default_selected" /> <!-- focused -->
<item android:drawable="@drawable/mach_selection_menu_default_normal" /> <!-- default -->
</selector>
Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/copybutton"
android:text = "Copy"
android:background="@drawable/mach_selection_menu_default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
</LinearLayout>
Drawable
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/mach_selection_menu_default_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/mach_selection_menu_default_selected" /> <!-- focused -->
<item android:drawable="@drawable/mach_selection_menu_default_normal" /> <!-- default -->
</selector>
Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/copybutton"
android:text = "Copy"
android:background="@drawable/mach_selection_menu_default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
</LinearLayout>
'공부 > Android' 카테고리의 다른 글
안드로이드에서 휠 모양 입력 구현 (0) | 2011.06.07 |
---|---|
안드로이드 액션바 어디서든 사용하기 (0) | 2011.06.05 |
안드로이드 HTML 파싱법 (0) | 2011.06.04 |
안드로이드 Frame 애니메이션 구현 (0) | 2011.04.04 |
안드로이드 메모장 튜터리얼 하기 (0) | 2010.08.24 |