스타일(Style) 다루기
스타일(Style)은 레이아웃 요소의 여러 속성들을 하나로 묶는 수단이다.
레이아웃 위젯들은 모두 기반 클래스View를 상속하고 View에는 유용한 공통 속성들이 많이 있다.
서로 관련된 속성들을 하나의 스타일로 묶어면, 관리와 사용이 편해 진다.
< /res/values/styles.xml >
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="my_style">
<item name="android:shadowColor">#FFFF0000</item>
<item name="android:shadowRadius">3</item>
<item name="android:shadowDx">2</item>
<item name="android:shadowDy">2</item>
</style>
</resources>
< /res/values/main.xml >
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
style="@style/my_style"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="ANDROID"/>
<TextView
style="@style/my_style"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="PROGRAM"/>
</LinearLayout>
'Resource' 카테고리의 다른 글
| 테마(Theme) 다루기 (0) | 2022.10.02 |
|---|---|
| 레이아웃 다루기 (0) | 2022.10.02 |
| 리소스에 대한 참조 (0) | 2022.10.02 |
| 원본(raw) 파일 다루기 (0) | 2022.10.02 |
| XML 파일 다루기 (0) | 2022.10.02 |
댓글