2020년도 이전/[WebSig] Android
style(스타일) 적용 및 theme(테마) 적용
시그시끄
2013. 8. 16. 12:43
결과화면

//values 폴더에 style.xml 에 다음 소스코드를 추가한다....
<style name="big_red_font"> <item name="android:textColor">#ff0000</item> <item name="android:textSize">25sp</item> </style>
|
//MainActivity.java
package com.example.widgetdemo1;
import android.os.Bundle; import android.app.Activity; import android.view.Menu;
public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.style_demo); }
}
|
//style_demo.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >
<TextView style="@style/big_red_font" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="스타일 big_red_font 적용" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="스타일 미적용" />
</LinearLayout>
|
theme(테마) 적용
1. style.xml에 소스코드 추가하고
2. Manifest에 추가한다. ===>>> <activity
android:theme="@string/mytheme"