A> 리소스의 종류
drawable: 이미지, 이미지와 관련된 XML, 그림을 표현한 XML
layout: 화면 UI를 정의한 레이아웃 XML
values: 문자열, 색상, 크기 등 여러 가지 값
menu: 액티비티의 메뉴를 구성하기 위한 XML
xml: 특정 폴더가 지정되어 있지 않은 기타 XML
anim: 애니메이션을 위한 XML
raw: 바이트 단위로 직접 이용되는 이진 파일
mipmap: 앱 아이콘 이미지
1.anim 리소스
1
2
3
4
5
6
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate/>
<rotate/>
<alpha/> //투명도
<scale/> //크기 조정
</set>
|
cs |
예시
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="true">
<scale
android:fromXScale="0.0"
android:toXScale="1.0"
android:fromYScale="0.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="0"
android:duration="2000"
/>
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:startOffset="0"
android:duration="2000"
/>
</set
|
cs |
2.크기, 색상, 스타일 등의 리소스
html 의 css와 비슷한 존재이다.
예시
1
2
3
4
5
6
7
8
9
10
11
|
<resources>
<dimen name="my_margin">16dp</dimen>
<dimen name="my_padding">16dp</dimen>
</resources>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:padding="@dimen/my_padding"
android:layout_margin="@dimen/my_margin"
/>
|
cs |
스타일 리소스 예시
1
2
3
4
5
6
7
8
9
10
11
|
<style name="myStyle">
<item name="android:textColor">#FF0000FF</item>
<item name="android:textSize">20dp</item>
<item name="android:textStyle">bold</item>
</style>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="First"
style="@style/myStyle"
/>
|
cs |