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

#contents

**テーマを作って指定 [#q82d6a19]
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」を指定することになります。~
&ref(./theme.png);

**UIパーツのプロパティ [#p7f03e8f]
|プロパティ            |概要                        |h
|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|配置方法指定                |
|プロパティ            |概要                        |例|h
|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|配置方法指定                ||

**参考 [#pf0ded79]
-[[テーマ機能を使ってアプリケーション全体にスタイルを適用させる方法>http://pentan.info/android/app/layout/theme.html]]
-[[よく使うUIパーツのプロパティ>http://pentan.info/android/app/layout/parts_property.html]]
-[[Android PreferenceActivity の背景をカスタマイズ>http://y-anz-m.blogspot.com/2011/02/androidpreferenceactivity.html]]
-[[Android style で windowBackground を設定するときの注意点>http://y-anz-m.blogspot.com/2011/02/androidstyle-windowbackground.html]]

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS