スタイルの指定

スタイルを指定することで、背景色や文字の色などを変更できます。

テーマを作って指定

res/valuesにstyle.xmlを作成し、その中にスタイルを定義する方法です。
(style.xmlで無くてもよいらしい)

XMLは以下のような感じで定義します。

#codeprettify{{

?xml version="1.0" encoding="utf-8"?>

resources>

   <style name="theme1">
       <item name="android:colorBackground">@color/background</item>
       <item name="android:windowBackground">@drawable/bg_blue</item>  
       </style>
   <style name="theme2">
       <item name="@android:style/Widget.ListView">@color/background</item>
       <item name="android:windowBackground">@drawable/bg_blue</item>  
       <item name="android:textColor">@color/listTextColor</item>  
       </style>

/resources> }}

で、この定義した内容をどこで使うかなんですが、res/layoutで定義する画面のレイアウトやAndroidManifest.xmlで利用します。
AndroidManifest.xmlでは、applicationタグのandroid:themeプロパティに設定します。

#codeprettify{{

   <application android:icon="@drawable/icon" 
                android:label="@string/app_name" 
                android:theme="@style/theme1">
       <activity android:name=".DemoActivity"
                 android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>

}}

Eclipseからだと、AndroidManifest.xmlの「アプリケーション」の項目の「Theme」を指定することになります。
theme.png

UIパーツのプロパティ

プロパティ概要
android:textColor文字の色指定
android:textSize文字のサイズ指定
android:textStyle文字のスタイル指定
android:background背景色の指定
android:layout_width幅指定
android:layout_height高さ指定
android:maxWidth最大幅指定
android:maxHeight最大高さ指定
android:maxLength最大文字数の指定
android:maxLines最大行数の指定
android:paddingパディングの指定
android:layout_marginマージンの指定
android:layout_gravity配置方法指定

参考


添付ファイル: filetheme.png 387件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2011-12-02 (金) 11:36:45