style

old/UI Design 2010. 2. 22. 20:40

styles.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources>
 
   
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
 
       
<item name="android:layout_width">fill_parent</item>
 
       
<item name="android:layout_height">wrap_content</item>
 
       
<item name="android:textColor">#00FF00</item>
 
       
<item name="android:typeface">monospace</item>
 
   
</style>
 
</resources>


R.style에서 다양한 속성들을 상속받아서 style로 사용한다.

(ex)
<style name="CodeFont" parent="@android:style/TextAppearance.Medium"> 

<style  name="Theme.CutomDialog" parent="android:style/Theme.Dialog">

 
상속받은 item을 정의 한다.
       
<item name="android:textColor">#00FF00</item> 
<item name="android:typeface">monospace</item>

<item name="android:windowBackground">@drawable/filled_box</item>


다른 곳에서 레이아웃을 불러와서 style을 적용하기도 한다.

[/drawable/filled_box.xml]
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#f0600000"/>
    <stroke android:width="3dp" color="#ffff8080"/>
    <corners android:radius="3dp" />
    <padding android:left="10dp" android:top="10dp"
        android:right="10dp" android:bottom="10dp" />
</shape>


사용하기
<EditText 
   
style="@style/Numbers"     ... />

이런 식으로 activity 전체에 style 적용하기도 한다.

[AndroidManifest.xml]
        <activity android:name=".ActivityCustomDialog"
                  android:label="@string/app_name"
                  android:theme="@style/Theme.CutomDialog">

'old > UI Design' 카테고리의 다른 글

Notification  (0) 2010.06.17
UI 이벤트 처리  (0) 2010.06.15
기본 UI 생성 순서  (0) 2010.02.22
R.anim  (0) 2010.02.22
R.integer  (0) 2010.02.22
Posted by jazzlife
,