開発メモ/Android/スタイルの指定
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*スタイルの指定 [#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/backg...
<item name="android:windowBackground">@drawable/b...
</style>
<style name="theme2">
<item name="@android:style/Widget.ListView">@colo...
<item name="android:windowBackground">@drawable/b...
<item name="android:textColor">@color/listTextCol...
</style>
</resources>
}}
で、この定義した内容をどこで使うかなんですが、res/layout...
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.acti...
<category android:name="android.intent.ca...
</intent-filter>
</activity>
}}
Eclipseからだと、AndroidManifest.xmlの「アプリケーション...
&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|配置方法指定 ||
**参考 [#pf0ded79]
-[[テーマ機能を使ってアプリケーション全体にスタイルを適用...
-[[よく使うUIパーツのプロパティ>http://pentan.info/androi...
-[[Android PreferenceActivity の背景をカスタマイズ>http:...
-[[Android style で windowBackground を設定するときの注...
終了行:
*スタイルの指定 [#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/backg...
<item name="android:windowBackground">@drawable/b...
</style>
<style name="theme2">
<item name="@android:style/Widget.ListView">@colo...
<item name="android:windowBackground">@drawable/b...
<item name="android:textColor">@color/listTextCol...
</style>
</resources>
}}
で、この定義した内容をどこで使うかなんですが、res/layout...
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.acti...
<category android:name="android.intent.ca...
</intent-filter>
</activity>
}}
Eclipseからだと、AndroidManifest.xmlの「アプリケーション...
&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|配置方法指定 ||
**参考 [#pf0ded79]
-[[テーマ機能を使ってアプリケーション全体にスタイルを適用...
-[[よく使うUIパーツのプロパティ>http://pentan.info/androi...
-[[Android PreferenceActivity の背景をカスタマイズ>http:...
-[[Android style で windowBackground を設定するときの注...
ページ名: