Android App2014. 8. 14. 16:28

일단 res/drawable 폴더가 없으면 만든다.

 

그안에 xml 파일을 하나 넣는다 예제로 button_state.xml로 이렇게 넣는다.

 

헷갈렸던거는 drawable-hdmi, drawable-xhdmi,drawable-xxhdmi 이렇게 각 해상도 별로 폴더가 있는데

 

다 넣어야 되어야하는건가란느 의문이였다...

 

하지만 버튼 눌렀을때 와 보통 이미지는 그냥 저 폴더에 넣고

 

xml 파일만 drawable에 담는다....

 

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
     <!-- selected -->
     <item android:state_selected="true"
        android:drawable="@drawable/btnfileviewer_press" />
     <!-- pressed -->
     <item android:state_pressed="true"
        android:drawable="@drawable/btnfileviewer_press" />
    <!-- focused -->
    <item android:state_focused="true"
        android:drawable="@drawable/btnfileviewer_press" />
    <!-- default -->
    <item android:drawable="@drawable/btnfileviewer_normal" />
</selector>

 

디폴트는 맨마지막에 넣어야 된다고 한다....

 

그리고 마지막으로 이미지 폴더에 저 selector를 적용한다.

 

 

<ImageButton
        android:id="@+id/imageButtonListOpen"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="68dp"
        android:background="@android:color/transparent"
        android:src="@drawable/fileviewerbuttonstate" />

 

src에 xml 파일이름을 넣어주면 된다.

 

android:src="@drawable/fileviewerbuttonstate"

 

참고한곳 : http://www.androes.com/99

 

'Android App' 카테고리의 다른 글

layout 가운데 정렬  (0) 2014.08.18
Action Bar 숨기기  (0) 2014.08.18
Custom ListView 만들기  (0) 2014.08.13
file size 나타내기 간략하게...  (0) 2014.08.13
텍스트 파일 및 이미지 파일 저장 하기  (0) 2014.08.12
Posted by 동동(이재동)