<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6569236911669928977</id><updated>2024-10-24T21:34:50.188+09:00</updated><category term="レイアウトXML講座"/><category term="基本編"/><category term="開発環境構築"/><category term="実践編(1)"/><category term="LinearLayout"/><category term="Eclipse"/><category term="レイアウトXML概要"/><category term="RelativeLayout"/><category term="エミュレータ"/><category term="DDMS"/><category term="デバッグ"/><category term="px)"/><category term="sp"/><category term="インポート"/><category term="スクリーンショット"/><category term="レイアウト種類"/><category term="単位(dp"/><title type='text'>WebデザイナーのためのAndroid用レイアウト講座</title><subtitle type='html'>Webプログラマ出身の僕がWebデザイナーの方のリクエストに応えてAndroid用レイアウト講座を開くよ！</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>36</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-8455488709147556432</id><published>2011-10-08T03:42:00.004+09:00</published><updated>2011-10-08T03:42:53.270+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="実践編(1)"/><title type='text'>Chapter15: 画面用javaファイルの簡単な説明</title><content type='html'>前回までで、とりあえずレイアウトの実践編は終わりにして、あとはちょっとJavaファイルの説明をしようと思います。とはいっても、あくまでもプログラムをガリガリ書くためということではなく、画面を増やしたりするときのために、必要な知識程度として、です。&lt;br /&gt;
&lt;br /&gt;
なお、説明するのは、たったこれだけの量なので、大丈夫だと思います。&lt;br /&gt;
これは、プロジェクトを作った時点で自動的に作られているソースと同じ量です。
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class Chapter11Activity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chapter11);
    }
    // 省略
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Activity(画面用ファイル)&lt;/span&gt;&lt;br /&gt;
Activityとは、画面用のクラスのことです。画面用のJavaファイルは、全てActivityクラスを継承しています。継承とは、指定しているクラスの機能を受け継ぐことを言います。機能(メソッド)の内容を書き換えたり、追記したり、新しい機能を追加したりします。&lt;br /&gt;
クラスを継承する場合は、extendsで指定します。

&lt;br /&gt;
&lt;pre class=&quot;brush:java;highlight:[1]&quot;&gt;public class Chapter11Activity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chapter11);
    }
    // 省略
}
&lt;/pre&gt;
とはいっても、新しく画面を追加したいときは、真っ新なファイルを作って、全部書かないといけないわけではありません。Eclipseでファイルを作成した時点で、かなり書いてくれます。
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Javaファイル(Activity)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;の作成方法&lt;/span&gt;&lt;br /&gt;
まず、パッケージ上で右クリックして、新規 &amp;gt; クラスを選択します。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxHkdiqJhvi5mdApAic8fc5JSMCCGmoBTTQmQ080y9nL9DuzIkYJoSn_266KQGwCTQ19sHHUs4TksGH07syp0JNWRZ85k1BAiM19fJKtZtVolP_mWSdLQtxgGGd8ykjA_ImnLLxOlEID0/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-08+2.54.23.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;113&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxHkdiqJhvi5mdApAic8fc5JSMCCGmoBTTQmQ080y9nL9DuzIkYJoSn_266KQGwCTQ19sHHUs4TksGH07syp0JNWRZ85k1BAiM19fJKtZtVolP_mWSdLQtxgGGd8ykjA_ImnLLxOlEID0/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-08+2.54.23.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
その後、名前に画面用ファイルの名前を記述します。&lt;br /&gt;
今回はTestActivityと書きましたが、別に～Activityで終わる必要はありません。&lt;br /&gt;
その後、スーパークラスを指定します。スーパークラスとは、継承元のクラスのことです。今回はActivityを継承します。基本的に指定する場合は、パッケージ名 + クラス名になるのですが、覚えていられないので、Eclipseの力を借ります。アシストです。&lt;br /&gt;
Activiくらいまで打った時点で、Ctrl + Spaceを押すと、ズラッと候補が出てきます。Activityを選択しましょう。その後、完了を押します。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigGvPln2rjenFBc3UDzfaNJES4Y8KtH_o6Ps5VP3LlTpT9SlJWmqCOBr-iNa6hrjBoSQbiMbAGwxkBl9Qko_WCDs3dJNN3o15ibCfn9BxlZLrvjvb9bHuFpmBMrS7V9WLFEOhoB54_8Zk/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-08+2.55.00.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigGvPln2rjenFBc3UDzfaNJES4Y8KtH_o6Ps5VP3LlTpT9SlJWmqCOBr-iNa6hrjBoSQbiMbAGwxkBl9Qko_WCDs3dJNN3o15ibCfn9BxlZLrvjvb9bHuFpmBMrS7V9WLFEOhoB54_8Zk/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-08+2.55.00.png&quot; width=&quot;351&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
これだけです。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
次は、onCreateメソッドの説明します。&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;onCreateメソッド&lt;/span&gt;&lt;br /&gt;
onCreateメソッドとは、Activityが画面を作る際に自動的に呼ばれるメソッドです。敢えてJavaScriptで例えるならば、Window.onLoadメソッドみたいなものと解釈してください。jQueryで言えば、readyメソッドです（細かい意味まで問われると全然違いますが。読み込み完了後に呼ばれるので）。&lt;br /&gt;
&lt;br /&gt;
継承元のメソッドを上書きする場合は、@Overrideという記述が要ります。&lt;br /&gt;
onCreateメソッドは基本的にこの形なので、このままコピー&amp;amp;ペーストしてもらって構いません。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java;highlight:[2,3]&quot;&gt;public class Chapter11Activity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chapter11);
    }
    // 省略
}
&lt;/pre&gt;
Androidに限らずですが、アプリケーションにはライフサイクルがあります。アプリが起動してから終了するまで（一時停止からの復帰含む）に、自動的に呼ばれるメソッドがあります。単に画面の確認をしたいだけだったら、onCreateメソッドだけ覚えておけばいいです。&lt;br /&gt;
&lt;br /&gt;
ライフサイクルについて深く学びたい場合は、&lt;a href=&quot;http://techbooster.jpn.org/andriod/environment/323/&quot;&gt;TechBoosterさんのライフサイクルの図解&lt;/a&gt;を見るとよいでしょう。&lt;br /&gt;
&lt;br /&gt;
では、次にonCreateメソッドの中で何をしているかを説明します。&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;onCreateメソッドの中でレイアウトファイルを指定&lt;/span&gt;&lt;br /&gt;
onCreateメソッドの中は2行しかないですね。画面を表示するだけだったら、実はこれだけでよいのです。

&lt;br /&gt;
&lt;pre class=&quot;brush:java;highlight:[4,5]&quot;&gt;public class Chapter11Activity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chapter11);
    }
    // 省略
}
&lt;/pre&gt;
4行目では、親クラス(ここではActivity)のonCreateメソッドを呼び出しています。&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;この処理は必須です。&lt;/span&gt;まぁ色々とやってくれてるんだなぁと思ってください（私もそう思ってます）。なお、superとは、作成のときにスーパークラスという表現があったと思いますが、親クラスを示す特別な変数です。Javaでプログラムしていると、ちょくちょく登場します。&lt;br /&gt;
&lt;br /&gt;
5行目で、この画面で使用するレイアウトXMLを指定しています。setContentViewとは、レイアウトを指定するActivity固有の命令（メソッド）です。ここでは、R.layout.chapter11を指定していますが、これは、/res/layout/chapter11.xmlのことを指します。&lt;br /&gt;
&lt;br /&gt;
これだけです。省略している部分はメニューボタンを押したときに表示されるメニューの動作についてのプログラムなので、あとは省略して、別の機会に取扱います。&lt;br /&gt;
&lt;br /&gt;
以上で、実践編(1)は終わりです。お疲れ様でした。&lt;br /&gt;
そして、ありがとうございました。&lt;br /&gt;
&lt;br /&gt;
また実践編(2)でお会いしましょう。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/8455488709147556432/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter15-java.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/8455488709147556432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/8455488709147556432'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter15-java.html' title='Chapter15: 画面用javaファイルの簡単な説明'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxHkdiqJhvi5mdApAic8fc5JSMCCGmoBTTQmQ080y9nL9DuzIkYJoSn_266KQGwCTQ19sHHUs4TksGH07syp0JNWRZ85k1BAiM19fJKtZtVolP_mWSdLQtxgGGd8ykjA_ImnLLxOlEID0/s72-c/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-08+2.54.23.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-2609546839510712110</id><published>2011-10-07T07:42:00.000+09:00</published><updated>2011-10-07T07:54:06.202+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="実践編(1)"/><title type='text'>Chapter14: スタイル適用の答え合わせ</title><content type='html'>Chapter13はできたでしょうか？&lt;br /&gt;
スタイルをまとめるというのは、CSSを書く感覚と同じなので、理解しやすかったのではないでしょうか？&lt;br /&gt;
では、コードを見てみましょう。Sample03プロジェクトの/res/values/sample_styles.xmlを開いてください。

&lt;pre class=&quot;brush:xml&quot;&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;resources&amp;gt;
    &amp;lt;style name=&quot;SampleTopBtnPort&quot;&amp;gt;
        &amp;lt;item name=&quot;android:layout_width&quot;&amp;gt;90dip&amp;lt;/item&amp;gt;
        &amp;lt;item name=&quot;android:layout_height&quot;&amp;gt;90dip&amp;lt;/item&amp;gt;
        &amp;lt;item name=&quot;android:adjustViewBounds&quot;&amp;gt;true&amp;lt;/item&amp;gt;
    &amp;lt;/style&amp;gt;
&amp;lt;/resources&amp;gt;
&lt;/pre&gt;
スタイルは、styleタグで定義します。&lt;br /&gt;
name属性がCSSのクラス名と同じと思ってください。&lt;br /&gt;
各スタイルの定義自身は、itemタグで設定します。&lt;br /&gt;
itemタグのname属性に、Viewの属性名を記述し、値を定義します。&lt;br /&gt;
敢えてCSSっぽく書くと、
&lt;pre class=&quot;brush:css&quot;&gt;
.SampleTopBtnPort {
    android:layout_width: 90dip;
    android:layout_height: 90dip;
    android:adjustViewBounds: true;
}
&lt;/pre&gt;
という感じでしょうか。&lt;br /&gt;
&lt;br /&gt;
これをViewに適用すると、以下のようになります。&lt;br /&gt;
/res/layout/chapter14.xmlの一部を抜粋&lt;br /&gt;
&lt;pre class=&quot;brush:xml; highlight:[10,14,17]&quot;&gt;
&amp;lt;LinearLayout
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:orientation=&quot;horizontal&quot;
    android:gravity=&quot;top|center_horizontal&quot;
    android:layout_marginBottom=&quot;10dp&quot;&amp;gt;
    &amp;lt;ImageView
        android:src=&quot;@drawable/regist&quot;
        android:layout_marginRight=&quot;10dp&quot;
        style=&quot;@style/SampleTopBtnPort&quot; /&amp;gt;
    &amp;lt;ImageView
        android:src=&quot;@drawable/manage&quot;
        android:layout_marginRight=&quot;10dp&quot;
        style=&quot;@style/SampleTopBtnPort&quot; /&amp;gt;
    &amp;lt;ImageView
        android:src=&quot;@drawable/photo_book&quot;
        style=&quot;@style/SampleTopBtnPort&quot; /&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
ImageViewのstyle属性に@style/SampleTopBtnPortを指定したことで、だいぶすっきりした見た目になったかと思います。
</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/2609546839510712110/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter14.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/2609546839510712110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/2609546839510712110'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter14.html' title='Chapter14: スタイル適用の答え合わせ'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-5994875231466852274</id><published>2011-10-07T06:20:00.000+09:00</published><updated>2011-10-07T06:20:51.003+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="実践編(1)"/><title type='text'>Chapter13: スタイルにまとめてみる</title><content type='html'>さて、Chapter12はクリアできたでしょうか？&lt;br /&gt;
以下のような画面になっていればOKです。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieMWQQNWkOPh2ZrGTbFooTD75YvnQvqC0WWqvLf9Jyh_c0i-Oc8Z0aqJvu5Ghp16axUYUo2m_fhqv3u61JDQwVK5Kdb0qUWJtcQoMoiWZUZVtITQ_D4lkcRDcx-qbUZhcjNE8UbRuDW7s/s1600/top.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieMWQQNWkOPh2ZrGTbFooTD75YvnQvqC0WWqvLf9Jyh_c0i-Oc8Z0aqJvu5Ghp16axUYUo2m_fhqv3u61JDQwVK5Kdb0qUWJtcQoMoiWZUZVtITQ_D4lkcRDcx-qbUZhcjNE8UbRuDW7s/s400/top.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
次は、見た目は変わらないまま、スタイルを作ってみましょう。&lt;br /&gt;
スタイルとは、CSSみたいなもので、レイアウトXML内で使うViewの属性をまとめたものです。スタイルを使うことで、レイアウトの修正を簡単にすることができますし、ソースの可読性が上がります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
コードレビュー&lt;/h4&gt;
では、コードを見てみましょう。Sample03プロジェクトの/res/layout/chapter13.xmlを開いてください。 

&lt;br /&gt;
&lt;pre class=&quot;brush:xml; highlight:[40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    android:background=&quot;@drawable/back_img_repeat&quot;&amp;gt;
    &amp;lt;RelativeLayout
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:paddingLeft=&quot;10dp&quot;
        android:paddingRight=&quot;10dp&quot;
        android:paddingTop=&quot;20dp&quot;
        android:paddingBottom=&quot;20dp&quot;&amp;gt;
        &amp;lt;ImageView
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:src=&quot;@drawable/logo&quot;
            android:adjustViewBounds=&quot;true&quot;
            android:layout_centerInParent=&quot;true&quot; /&amp;gt;
    &amp;lt;/RelativeLayout&amp;gt;
    &amp;lt;LinearLayout
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;0dp&quot;
        android:layout_weight=&quot;1&quot;
        android:orientation=&quot;vertical&quot;
        android:gravity=&quot;bottom&quot;
        android:layout_marginBottom=&quot;10dp&quot;&amp;gt;
        &amp;lt;!-- 
            ImageViewで定義している属性をstyleに書き換えてください。
            ファイル名はstyles.xml
            style名はTopBtnPortで作成してください。
         --&amp;gt;
        &amp;lt;LinearLayout
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:orientation=&quot;horizontal&quot;
            android:gravity=&quot;top|center_horizontal&quot;
            android:layout_marginBottom=&quot;10dp&quot;&amp;gt;
            &amp;lt;ImageView
                android:src=&quot;@drawable/regist&quot;
                android:layout_marginRight=&quot;10dp&quot;
                android:layout_width=&quot;90dp&quot;
                android:layout_height=&quot;90dp&quot;
                android:adjustViewBounds=&quot;true&quot; /&amp;gt;
            &amp;lt;ImageView
                android:src=&quot;@drawable/manage&quot;
                android:layout_marginRight=&quot;10dp&quot;
                android:layout_width=&quot;90dp&quot;
                android:layout_height=&quot;90dp&quot;
                android:adjustViewBounds=&quot;true&quot; /&amp;gt;
            &amp;lt;ImageView
                android:src=&quot;@drawable/photo_book&quot;
                android:layout_width=&quot;90dp&quot;
                android:layout_height=&quot;90dp&quot;
                android:adjustViewBounds=&quot;true&quot; /&amp;gt;
        &amp;lt;/LinearLayout&amp;gt;
        &amp;lt;LinearLayout
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:orientation=&quot;horizontal&quot;
            android:gravity=&quot;top|center_horizontal&quot;&amp;gt;
            &amp;lt;ImageView
                android:src=&quot;@drawable/ranking&quot;
                android:layout_marginRight=&quot;10dp&quot;
                android:layout_width=&quot;90dp&quot;
                android:layout_height=&quot;90dp&quot;
                android:adjustViewBounds=&quot;true&quot; /&amp;gt;
            &amp;lt;ImageView
                android:src=&quot;@drawable/about&quot;
                android:layout_marginRight=&quot;10dp&quot;
                android:layout_width=&quot;90dp&quot;
                android:layout_height=&quot;90dp&quot;
                android:adjustViewBounds=&quot;true&quot; /&amp;gt;
            &amp;lt;View
                android:layout_width=&quot;90dp&quot;
                android:layout_height=&quot;90dp&quot;
                android:adjustViewBounds=&quot;true&quot; /&amp;gt;
        &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;RelativeLayout
        android:id=&quot;@+id/adArea&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;50dp&quot;&amp;gt;
        &amp;lt;ImageView
            android:src=&quot;@drawable/nail_banner&quot;
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;50dp&quot;
            android:layout_centerInParent=&quot;true&quot; /&amp;gt;
    &amp;lt;/RelativeLayout&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
Chapter12の答え合わせですが、ここではボタンでなくImageViewを使っています。ImageButtonというViewもあるのですが、ボタン用の縁などがつくので、そういうものがいらない場合は、ImageViewで作ってしまったほうが手っ取り早いと思っています。&lt;br /&gt;
&lt;br /&gt;
75行目のViewですが、ここでは表示する画像がないので、敢えて何も表示しないViewを配置しています。何も表示しないViewを配置するというのも、テクニックになってきます（最初思いつきませんでしたが、他の方のソースを見たりして、こういう方法もあるのかと気づきました）。&lt;br /&gt;
&lt;br /&gt;
Chapter13の課題の「スタイルにまとめてみる」ですが、参考になるソースは、/res/layout/chapter14.xmlと、/res/values/sample_styles.xmlになります。参考にして挑戦してみてください。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/5994875231466852274/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter13.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/5994875231466852274'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/5994875231466852274'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter13.html' title='Chapter13: スタイルにまとめてみる'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieMWQQNWkOPh2ZrGTbFooTD75YvnQvqC0WWqvLf9Jyh_c0i-Oc8Z0aqJvu5Ghp16axUYUo2m_fhqv3u61JDQwVK5Kdb0qUWJtcQoMoiWZUZVtITQ_D4lkcRDcx-qbUZhcjNE8UbRuDW7s/s72-c/top.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-1974158254220405877</id><published>2011-10-07T04:55:00.000+09:00</published><updated>2011-10-07T04:55:48.183+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="実践編(1)"/><title type='text'>Chapter12: ボタンを表示させる</title><content type='html'>さて、Chapter11はクリアできたでしょうか？&lt;br /&gt;
以下のような画面になっていればOKです。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHN-Rfo1XyWsX5xT9KCeDG1625sT2Y6CgJMZN5OBYZWkm_w9SB-VhGDUxgb4c7_QYs7lvnkry6UavagNwAjVYppEwx6aOaWhYLxy55cTYmUitgaFQctqEmrlxxyoFOqE5u9ryWs7e_xeE/s1600/device-2011-10-06-033752.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHN-Rfo1XyWsX5xT9KCeDG1625sT2Y6CgJMZN5OBYZWkm_w9SB-VhGDUxgb4c7_QYs7lvnkry6UavagNwAjVYppEwx6aOaWhYLxy55cTYmUitgaFQctqEmrlxxyoFOqE5u9ryWs7e_xeE/s400/device-2011-10-06-033752.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
次はこの画面にボタンを表示させます。&lt;br /&gt;
ボタンといっても、コスメマネージャーの場合はImageViewを使って画像を表示させています。&lt;br /&gt;
以下のような画面になります。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieMWQQNWkOPh2ZrGTbFooTD75YvnQvqC0WWqvLf9Jyh_c0i-Oc8Z0aqJvu5Ghp16axUYUo2m_fhqv3u61JDQwVK5Kdb0qUWJtcQoMoiWZUZVtITQ_D4lkcRDcx-qbUZhcjNE8UbRuDW7s/s1600/top.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieMWQQNWkOPh2ZrGTbFooTD75YvnQvqC0WWqvLf9Jyh_c0i-Oc8Z0aqJvu5Ghp16axUYUo2m_fhqv3u61JDQwVK5Kdb0qUWJtcQoMoiWZUZVtITQ_D4lkcRDcx-qbUZhcjNE8UbRuDW7s/s400/top.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
課題については、Chapter12のレイアウトファイル内に書かれています。
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
コードレビュー&lt;/h4&gt;
では、コードを見てみましょう。Sample03プロジェクトの/res/layout/chapter12.xmlを開いてください。

&lt;br /&gt;
&lt;pre class=&quot;brush:xml; highlight:[16,17,18,19,20,21,74,75,76,77,78]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    android:background=&quot;@drawable/back_img_repeat&quot;&amp;gt;
    &amp;lt;!-- ロゴを入れるRelativeLayout --&amp;gt;
    &amp;lt;RelativeLayout
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:paddingLeft=&quot;10dp&quot;
        android:paddingRight=&quot;10dp&quot;
        android:paddingTop=&quot;20dp&quot;
        android:paddingBottom=&quot;20dp&quot;&amp;gt;
        &amp;lt;ImageView
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:src=&quot;@drawable/logo&quot;
            android:adjustViewBounds=&quot;true&quot;
            android:layout_centerInParent=&quot;true&quot; /&amp;gt;
    &amp;lt;/RelativeLayout&amp;gt;
    &amp;lt;!-- メニューを入れるLinearLayout --&amp;gt;
    &amp;lt;LinearLayout
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;0dp&quot;
        android:layout_weight=&quot;1&quot;
        android:orientation=&quot;vertical&quot;&amp;gt;
        &amp;lt;LinearLayout
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:orientation=&quot;horizontal&quot;
            android:gravity=&quot;top|center_horizontal&quot;
            android:layout_marginBottom=&quot;10dp&quot;&amp;gt;
            &amp;lt;!-- 
                ImageViewを3つ使ってボタンを作成してください
                srcは
                @drawable/regist
                @drawable/manage
                @drawable/photo_book
                を使ってください。
                layout_widthは90
                layout_heightは90
                adjustViewBoundsはtrue
                を指定すること。
                他に使う属性もあります。
             --&amp;gt;
        &amp;lt;/LinearLayout&amp;gt;
        &amp;lt;LinearLayout
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:orientation=&quot;horizontal&quot;
            android:gravity=&quot;top|center_horizontal&quot;&amp;gt;
            &amp;lt;!-- 
                ImageViewを2つ使ってボタンを作成してください
                srcは
                @drawable/ranking
                @drawable/about
                を使ってください。
                layout_widthは90
                layout_heightは90
                adjustViewBoundsはtrue
                を指定すること。
                他に使う属性もあります。
                また、もう1つViewを追加して見た目を整えてください。
             --&amp;gt;
        &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;!-- フッター(広告エリア)など --&amp;gt;
    &amp;lt;RelativeLayout
        android:id=&quot;@+id/adArea&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;50dp&quot;&amp;gt;
        &amp;lt;ImageView
            android:src=&quot;@drawable/nail_banner&quot;
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;50dp&quot;
            android:layout_centerInParent=&quot;true&quot; /&amp;gt;
    &amp;lt;/RelativeLayout&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
Chapter11の答え合わせですが、ハイライトしている部分がそうです。&lt;br /&gt;
ImageViewで画像を指定する場合、@drawable/[ファイル名]を使います。&lt;br /&gt;
&lt;br /&gt;
余談ですが、このファイルは、/res/drawable-hdpiに置いています。&lt;br /&gt;
いろんな解像度に対応しようと思ったら、drawable-****のすべてに画像を置くべきですが、hdpiの画像のみを置いています。
優先順位的に画像が使われるので、mdpiの端末でも、drawable-mdpiに同名のファイルがない場合はdrawable-hdpiにある画像が使われます。
全ての解像度の画像を準備しようと思うと、大変ですし、アプリ自体のファイルサイズも大きくなるので、表示が合わない素材だけを、
特定のフォルダに置くようにしましょう。&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;また、デフォルトだとdrawableのフォルダのみ-hdpiや-mdpiという指定がありますが、実はlayoutファイルでもこのような指定をすることができます。詳細は今回は書きませんが、&lt;a href=&quot;http://developer.android.com/intl/ja/guide/practices/screens_support.html&quot;&gt;Android Developersの開発ガイドのマルチスクリーンのページ&lt;/a&gt;を見れば参考になるかと思います。&lt;br /&gt;
&lt;br /&gt;
Chapter12の解答はChapter13に書いてあるので、わからない場合はそちらを見ながら書いてみましょう。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/1974158254220405877/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter12.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/1974158254220405877'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/1974158254220405877'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter12.html' title='Chapter12: ボタンを表示させる'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHN-Rfo1XyWsX5xT9KCeDG1625sT2Y6CgJMZN5OBYZWkm_w9SB-VhGDUxgb4c7_QYs7lvnkry6UavagNwAjVYppEwx6aOaWhYLxy55cTYmUitgaFQctqEmrlxxyoFOqE5u9ryWs7e_xeE/s72-c/device-2011-10-06-033752.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-3094303195099597315</id><published>2011-10-06T04:37:00.000+09:00</published><updated>2011-10-06T04:37:24.466+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="実践編(1)"/><title type='text'>Chapter11: ロゴとフッターを表示させる</title><content type='html'>さて、Sample03のインポートは終わっているでしょうか？&lt;br /&gt;
「タイトルバーを消す」をしている人はもうしているかもしれません。まだの人は、「&lt;a href=&quot;http://chariderpato.blogspot.com/2011/10/sample03.html&quot;&gt;Sample03プロジェクトを公開しました&lt;/a&gt;」より、インポートしてください。&lt;br /&gt;
&lt;br /&gt;
今回の課題からは、実践方式になっています。&lt;br /&gt;
今までは基本的にソースコードを読んでもらう方式でしたが、手を動かさないとなかなか覚えられないと思いますので、そうしてみました。&lt;br /&gt;
Chapter11の完成コードがChapter12に、Chapter12の完成コードがChapter13に、Chapter13の完成コードがChapter14になっています。&lt;br /&gt;
&lt;br /&gt;
では、Chapter11の最初の画面を見てみましょう。&lt;br /&gt;
Sample03アプリを起動しましょう。最初の画面は、完成予定画面です。メニューボタンを押して、chapter11をタップしてみましょう。以下の画面が表示されます。&lt;br /&gt;
&lt;br /&gt;
背景だけ適用されているプレーンな画面です。&lt;br /&gt;
Chapter11では、ロゴとフッターをつけてもらいます。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWFoHH6ZKEzPctgFD0Ta84F3Ea3CoAv5Dpf3-tutOFTrIptfNA2VS_itH-3le8IIgTmBIboEH5IyLktE6aDt6wnV2-7b10uyBgO8UfYmfI-oMkXkP8KEyP3bgMRcmCJsQNhK43anmOFUQ/s1600/device-2011-10-06-033719.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWFoHH6ZKEzPctgFD0Ta84F3Ea3CoAv5Dpf3-tutOFTrIptfNA2VS_itH-3le8IIgTmBIboEH5IyLktE6aDt6wnV2-7b10uyBgO8UfYmfI-oMkXkP8KEyP3bgMRcmCJsQNhK43anmOFUQ/s400/device-2011-10-06-033719.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
完成イメージは以下になります。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHN-Rfo1XyWsX5xT9KCeDG1625sT2Y6CgJMZN5OBYZWkm_w9SB-VhGDUxgb4c7_QYs7lvnkry6UavagNwAjVYppEwx6aOaWhYLxy55cTYmUitgaFQctqEmrlxxyoFOqE5u9ryWs7e_xeE/s1600/device-2011-10-06-033752.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHN-Rfo1XyWsX5xT9KCeDG1625sT2Y6CgJMZN5OBYZWkm_w9SB-VhGDUxgb4c7_QYs7lvnkry6UavagNwAjVYppEwx6aOaWhYLxy55cTYmUitgaFQctqEmrlxxyoFOqE5u9ryWs7e_xeE/s400/device-2011-10-06-033752.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
課題はコード内に書かれていますが、コードのみ置いておきます。&lt;br /&gt;
Chapter11自体の答え合わせはChapter12で行います。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;コードレビュー&lt;/h4&gt;
では、コードを見てみましょう。Sample03プロジェクトの/res/layout/chapter11.xmlを開いてください。
&lt;pre class=&quot;brush: xml; highlight:[16, 30]&quot;&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    android:background=&quot;@drawable/back_img_repeat&quot;&amp;gt;
    &amp;lt;!-- ロゴを入れるRelativeLayout --&amp;gt;
    &amp;lt;RelativeLayout
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:paddingLeft=&quot;10dp&quot;
        android:paddingRight=&quot;10dp&quot;
        android:paddingTop=&quot;20dp&quot;
        android:paddingBottom=&quot;20dp&quot;&amp;gt;
        &amp;lt;!-- ImageViewを使って@drawable/logoを入れてください --&amp;gt;
    &amp;lt;/RelativeLayout&amp;gt;
    &amp;lt;!-- メニューを入れるLinearLayout --&amp;gt;
    &amp;lt;LinearLayout
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;0dp&quot;
        android:layout_weight=&quot;1&quot;
        android:orientation=&quot;vertical&quot;&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;!-- フッター(広告エリア)など --&amp;gt;
    &amp;lt;RelativeLayout
        android:id=&quot;@+id/adArea&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;50dp&quot;&amp;gt;
        &amp;lt;!-- ImageViewを使って@drawable/nail_bannerを入れてください --&amp;gt;
    &amp;lt;/RelativeLayout&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
課題の行をハイライトしています。
回答はChapter12になるので、chapter12.xmlを開いて参考にしてもらっても構いませんが、できればコピペしないでください。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/3094303195099597315/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter11.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/3094303195099597315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/3094303195099597315'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter11.html' title='Chapter11: ロゴとフッターを表示させる'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWFoHH6ZKEzPctgFD0Ta84F3Ea3CoAv5Dpf3-tutOFTrIptfNA2VS_itH-3le8IIgTmBIboEH5IyLktE6aDt6wnV2-7b10uyBgO8UfYmfI-oMkXkP8KEyP3bgMRcmCJsQNhK43anmOFUQ/s72-c/device-2011-10-06-033719.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-2279608468948267770</id><published>2011-10-06T03:15:00.000+09:00</published><updated>2011-10-06T03:16:09.316+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><category scheme="http://www.blogger.com/atom/ns#" term="実践編(1)"/><title type='text'>タイトルバーを消す方法</title><content type='html'>Chapter11にしようかと思いましたが、あまりにも簡単だし、汎用的な内容でもあるので、ChapterではなくTips扱いにします。&lt;br /&gt;
&lt;br /&gt;
Sample03プロジェクトで、コスメマネージャーのトップページを作るというのを題材に扱おうとしていますが、トップページは、アプリによりますが、タイトルバーを消したりする場合があります。コスメマネージャーはトップにロゴがあるので、タイトルバーを消しています。&lt;br /&gt;
&lt;br /&gt;
そこで、タイトルバーを消す方法です。&lt;br /&gt;
サンプル画面を見てみましょう。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXiT-s1eo7kyaeTAwb_axaHqDy14WNnLdvHI_jxJcJPd2omZDKmXx9Km6NvDGoY7wZW_vW-iEeGh4I7A6FZ6IUnt7XOUdOTYnQsxEWmE7D_IrzPSQO6yv-QeixkJG9HnvjzWN1T_eHJbI/s1600/top+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXiT-s1eo7kyaeTAwb_axaHqDy14WNnLdvHI_jxJcJPd2omZDKmXx9Km6NvDGoY7wZW_vW-iEeGh4I7A6FZ6IUnt7XOUdOTYnQsxEWmE7D_IrzPSQO6yv-QeixkJG9HnvjzWN1T_eHJbI/s400/top+2.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
タイトルバーを消すのは、レイアウトのXMLファイルからではできません。できるのはAndroidManifest.xmlファイルで、です。&lt;br /&gt;
AndroidManifest.xmlファイルは、Androidで使うAPIについて定義したり、使う画面用Javaファイルの定義をしたり、アプリのバージョン情報を書いたりする設定ファイルです。&lt;br /&gt;
&lt;br /&gt;
アプリで統一したいテーマを定義する場合はapplicationタグでテーマ属性を定義しますが、&lt;br /&gt;
画面(Activity)毎にテーマを設定することも可能です。&lt;br /&gt;
画面Aではタイトルバーを表示したいが、画面Bでは消したいということもありますから、今回の例ではActivity単位で消してみます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;


コードレビュー&lt;/h4&gt;
ではレイアウトのコードを見てみましょう。 Sample03プロジェクトの/AndroidManifest.xmlを開いてください。 

&lt;br /&gt;
&lt;pre class=&quot;brush:xml; highlight:[14]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;manifest
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    package=&quot;com.okolabo.android.sample03&quot;
    android:versionCode=&quot;1&quot;
    android:versionName=&quot;1.0&quot;&amp;gt;
    &amp;lt;uses-sdk android:minSdkVersion=&quot;7&quot; /&amp;gt;
    &amp;lt;application
        android:icon=&quot;@drawable/icon&quot;
        android:label=&quot;@string/app_name&quot;&amp;gt;
        &amp;lt;activity
            android:name=&quot;.SampleActivity&quot;
            android:label=&quot;@string/app_name&quot;
            android:theme=&quot;@android:style/Theme.NoTitleBar&quot;&amp;gt;
            &amp;lt;intent-filter&amp;gt;
                &amp;lt;action android:name=&quot;android.intent.action.MAIN&quot; /&amp;gt;
                &amp;lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&amp;gt;
            &amp;lt;/intent-filter&amp;gt;
        &amp;lt;/activity&amp;gt;
        &amp;lt;activity
            android:name=&quot;.Chapter11Activity&quot;
            android:theme=&quot;@android:style/Theme.NoTitleBar&quot; /&amp;gt;
        &amp;lt;activity
            android:name=&quot;.Chapter12Activity&quot;
            android:theme=&quot;@android:style/Theme.NoTitleBar&quot; /&amp;gt;
        &amp;lt;activity
            android:name=&quot;.Chapter13Activity&quot;
            android:theme=&quot;@android:style/Theme.NoTitleBar&quot; /&amp;gt;
        &amp;lt;activity
            android:name=&quot;.Chapter14Activity&quot;
            android:theme=&quot;@android:style/Theme.NoTitleBar&quot; /&amp;gt;
    &amp;lt;/application&amp;gt;
&amp;lt;/manifest&amp;gt;
&lt;/pre&gt;
最初のactivityタグのandroid:theme属性で、androidがデフォルトで持っているテーマを呼び出しています。android:themeを何も指定しない場合、&lt;br /&gt;
&lt;br /&gt;
@android:style/Theme&lt;br /&gt;
&lt;br /&gt;
が適用されます。今回はタイトルバーを消したかったので、&lt;br /&gt;
&lt;br /&gt;
@android:style/Theme.NoTitleBar&lt;br /&gt;
&lt;br /&gt;
を指定しています。また、タイトルバーだけでなく、ステータスバーも消してフルスクリーンにしたい場合は、&lt;br /&gt;
&lt;br /&gt;
@android:style/Theme.NoTitleBar.FullScreen&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
を指定します。黒めのテーマを使う場合は@android:style/Theme.Black系を、白めのテーマを使う場合は、@android:style/Theme.Light系を使います。基本の背景色や、メニューボタンを押して出てくるメニューの色などが変わるので、プレーンな感じでいい場合は好きなほうをテーマとして選びましょう（デフォルトは黒系）&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
なお、ここでは詳しくは解説しませんが、テーマは継承できます。&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;わかりやすくいうと、デフォルトのCSSを使って、気に入らないところだけ自分で上書きして新しいテーマを作ることができるということです。&lt;/span&gt;1から全部書かなくてもよいですし、全部自分で書くとAndroidアプリケーションとして他アプリとしての統一性がなくなるので、基本的にはテーマを継承して新しいテーマを定義したほうがよいでしょう。&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/2279608468948267770/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/2279608468948267770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/2279608468948267770'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/blog-post.html' title='タイトルバーを消す方法'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXiT-s1eo7kyaeTAwb_axaHqDy14WNnLdvHI_jxJcJPd2omZDKmXx9Km6NvDGoY7wZW_vW-iEeGh4I7A6FZ6IUnt7XOUdOTYnQsxEWmE7D_IrzPSQO6yv-QeixkJG9HnvjzWN1T_eHJbI/s72-c/top+2.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-3534212254663881516</id><published>2011-10-06T02:24:00.003+09:00</published><updated>2011-10-07T07:43:30.076+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="実践編(1)"/><title type='text'>Sample03プロジェクトを公開しました</title><content type='html'>前回までで、Sample02のプロジェクトの内容が終わりました。&lt;br /&gt;
&amp;nbsp;次のプロジェクトを準備してあるので、Sample03プロジェクトをダウンロードしてインポートしてください。やり方は、&lt;a href=&quot;http://chariderpato.blogspot.com/2011/09/eclipsezip.html&quot;&gt;Eclipseでプロジェクトをインポートする(zipのまま)&lt;/a&gt;です。ダウンロードするURLの部分だけ、読み替えてください。よろしくお願いします。
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://github.com/patorash/AndroidLayoutXmlStudy-Sample03&quot;&gt;Sample03プロジェクトへのリンク(github)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Sample03で扱う内容は、以下の通りです。&lt;br /&gt;
今回は著者が公開しているAndroidアプリの「&lt;a href=&quot;https://market.android.com/details?id=jp.cyclemate.android.cosmemanager&quot;&gt;コスメマネージャー&lt;/a&gt;」のトップ画面を作ります。&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;タイトルバーを消す&lt;/li&gt;
&lt;li&gt;(Chapter11)ロゴとフッターを表示させる&lt;/li&gt;
&lt;li&gt;(Chapter12)ボタンを表示させる&lt;/li&gt;
&lt;li&gt;(Chapter13)スタイルを作成する&lt;/li&gt;
&lt;li&gt;(Chapter14)スタイル適用の答え合わせ&lt;/li&gt;
&lt;li&gt;(Chapter15)画面用javaファイルの簡単な説明&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/3534212254663881516/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/sample03.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/3534212254663881516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/3534212254663881516'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/sample03.html' title='Sample03プロジェクトを公開しました'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-4353851940284376073</id><published>2011-10-04T23:26:00.001+09:00</published><updated>2011-10-04T23:26:48.713+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="開発環境構築"/><title type='text'>Eclipseのショートカット集</title><content type='html'>※これは私がよく使うショートカットというだけです。&lt;br /&gt;
&lt;br /&gt;
動作が重たいEclipseが使われる理由として、開発者に便利な機能がたくさんあるからというのがあります。それを使いこなさないと、単に重たい動作のエディタということになってしまいます。&lt;br /&gt;
&lt;br /&gt;
ここでは私が開発のときによく使うショートカットを紹介します。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
●Ctrl + Space: アシスト&lt;br /&gt;
AdobeのDWでもある機能ですから、アシストの意味はわかるかと思いますが一応。&lt;br /&gt;
入力の候補を表示してくれます。この機能のおかげで、タグをあんまり覚えたりしなくてもだいたいわかります。便利です。これがないと開発できない気持ちになってしまうくらいです。
&lt;br /&gt;
&lt;div&gt;
Javaに限らず、xmlファイルでも使うことができます。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilR4UJpxwEEIJKIOTzmDsHfaw6JbuaH7M-kIwfewRY1ZHEPUFtusaKAh8UQdk8DDhv4ZEDz-7CKv_r4a4EBTAKYlqtiPFXuMWQWhu5PBoJmAyijvZ8agx3f2YPTp5tLqDBzqIwgSuvBVU/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.33.06.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilR4UJpxwEEIJKIOTzmDsHfaw6JbuaH7M-kIwfewRY1ZHEPUFtusaKAh8UQdk8DDhv4ZEDz-7CKv_r4a4EBTAKYlqtiPFXuMWQWhu5PBoJmAyijvZ8agx3f2YPTp5tLqDBzqIwgSuvBVU/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.33.06.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;lt;Lを入力した時点で候補が出てきますが、カーソル移動させて表示が消えてしまったときなど、もう一度表示させようと思ったら、Ctrl + Spaceを入力します(Win, Mac共通)。
Macの場合は、Ctrl + SpaceがSpotlightのショートカットに割り当てられているので、それを無効化しておく必要があります。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIRx6VFPs-27pKBjTK6A_wd9NYntaBl8mjxzPiFal6oVgEZVCp9MYr7ed0lzxNfrBRt8E8Zl9xVMCUijYWe-CODAK6ju6sV_ekDQzLaI8vUImOxUrG4B0PEu60Ci8qfTZo4trLkwll9IY/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.12.39.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;137&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIRx6VFPs-27pKBjTK6A_wd9NYntaBl8mjxzPiFal6oVgEZVCp9MYr7ed0lzxNfrBRt8E8Zl9xVMCUijYWe-CODAK6ju6sV_ekDQzLaI8vUImOxUrG4B0PEu60Ci8qfTZo4trLkwll9IY/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.12.39.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
タグが追加されました。続けて、android:layout_widthを入力したいと思います。&lt;br /&gt;
laと入力して、Ctrl + Spaceで、ずらーっと候補が出てきます。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSWg7VyPDxsRD7UzvLEc3BLhv2uFdNRIvtxiZKGYizsgNU4JO1rs1_QzwlaYxGMOMNxvIyl0apxmO0GBr7qsettXAV2prhPj7ja4t6U159WTrAk7UvbQJ7OtLfdJmDGcpiumdA9k8Iq6I/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.13.05.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;152&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSWg7VyPDxsRD7UzvLEc3BLhv2uFdNRIvtxiZKGYizsgNU4JO1rs1_QzwlaYxGMOMNxvIyl0apxmO0GBr7qsettXAV2prhPj7ja4t6U159WTrAk7UvbQJ7OtLfdJmDGcpiumdA9k8Iq6I/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.13.05.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
layout_widthを選択後、再びCtrl + Spaceを&quot;&quot;の間で押すと候補が表示されます。こんな感じでポンポン選択していくだけでよいことが多いので、コーディング量は相当減ります。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDOn_58ihBLjyTW6iIoKWV3Wp1s0ZbMDhAq5R6GJniUb6zmP3lv9Wq3ze3sRkH2GsyGlh58i7f67_kMDd5YIun8n-qLLhUJPNWGdHfkLE7CmrC60upmy_lgHSRK2IxKpZiwWpWZWl6uqA/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.13.26.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;186&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDOn_58ihBLjyTW6iIoKWV3Wp1s0ZbMDhAq5R6GJniUb6zmP3lv9Wq3ze3sRkH2GsyGlh58i7f67_kMDd5YIun8n-qLLhUJPNWGdHfkLE7CmrC60upmy_lgHSRK2IxKpZiwWpWZWl6uqA/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.13.26.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
●Ctrl(Command) + Shift + F: ソースコードの整形&lt;br /&gt;
ぐちゃぐちゃになったソースコードを見やすい形に整形してくれます。&lt;br /&gt;
ただし、機械的に行われるので、コメントを見やすく書いていたつもりでも、それも機械的に整理されてしまうので、気を付けて使う必要がある場合があります。&lt;br /&gt;
&lt;br /&gt;
こんな汚いソースでも・・・&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR__evljbi02G-NWvs0m6kowvf38fXl484AqIk7b9q4j4h5q3sO2vQ-6rx04hbD9Roh9RgaTBdqUKi_e8397YGpSiUIXE20jMIFCcc4MVN7Rmyn-cTTTvmzWy6SNlEHOnyxVX5ZtuFXVs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.45.44.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;56&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR__evljbi02G-NWvs0m6kowvf38fXl484AqIk7b9q4j4h5q3sO2vQ-6rx04hbD9Roh9RgaTBdqUKi_e8397YGpSiUIXE20jMIFCcc4MVN7Rmyn-cTTTvmzWy6SNlEHOnyxVX5ZtuFXVs/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.45.44.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;一発で綺麗に整形してくれます！&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ-Hqxx9rYMJXfT-gZwhybglPrXdfN0y5vqUdLFn0mxaMNeszi7kAnzGu2oi9f4HCFULppFVZzGzPj93IfnLHLAqveZBkvb6QHPxmO0uXB78Wp8Tk2MlbF73Ut_8XC5Jb1wGvRRbHxTMg/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.46.35.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;81&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ-Hqxx9rYMJXfT-gZwhybglPrXdfN0y5vqUdLFn0mxaMNeszi7kAnzGu2oi9f4HCFULppFVZzGzPj93IfnLHLAqveZBkvb6QHPxmO0uXB78Wp8Tk2MlbF73Ut_8XC5Jb1wGvRRbHxTMg/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.46.35.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
●Ctrl(Command)&amp;nbsp;+ Shift + O: 必要なパッケージの自動インポート(Java)&lt;br /&gt;
プログラムも多少いじらないといけなくなると思いますので、それのサポートとして。プログラマの人は知っておいたほうが超便利です。&lt;br /&gt;
Javaのパッケージは膨大にあって、もちろん全部覚えられるわけもなく、長いソースコードになれば、どのパッケージを使っていて、どのパッケージを使わなくなったかなど、知る由もありません。&lt;br /&gt;
そこで、Ctrl + Shift + O(オー)を押すと、必要なパッケージの自動インポートを行ってくれます。&lt;br /&gt;
&lt;br /&gt;
下のソースのように、Intentクラスをインポートしていなくてエラーになったり、使わなくなったProgressBarクラスがあったとします。ここで、Ctrl + Shift + Oを押します。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOLwEYui1oA-H9fnu4XjxfV9fbx_i8oyyGcRN4EOZCVm2gYzjgFXI588pRzg9LtQIlmNGFGbadYB59CryPZSjdrv7PtQnoq1PPKtXx7z3MLg7u0QjPw-FD3-GtlhX5klV91gUhIUYJqms/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+23.00.50.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOLwEYui1oA-H9fnu4XjxfV9fbx_i8oyyGcRN4EOZCVm2gYzjgFXI588pRzg9LtQIlmNGFGbadYB59CryPZSjdrv7PtQnoq1PPKtXx7z3MLg7u0QjPw-FD3-GtlhX5klV91gUhIUYJqms/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+23.00.50.png&quot; width=&quot;306&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
すると、なんということでしょう。&lt;br /&gt;
import文が綺麗に整形され、エラーが消え去ったではありませんか。&lt;br /&gt;
これも、匠(Eclipse)のなせる業です。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwZLZWUFPqPyq147J5obdesXMZlBGi4PiATdKCeClGmc3RWpBatr4dAH-YmgeEo8y57quNZCUA5NwLQY3JzWKt9zDOjINXNxp46xSCrwNQ5kV7LjWLe69NbdkMFlCLiJBnR-IcD79TgJU/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+23.08.22.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwZLZWUFPqPyq147J5obdesXMZlBGi4PiATdKCeClGmc3RWpBatr4dAH-YmgeEo8y57quNZCUA5NwLQY3JzWKt9zDOjINXNxp46xSCrwNQ5kV7LjWLe69NbdkMFlCLiJBnR-IcD79TgJU/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+23.08.22.png&quot; width=&quot;305&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
●Ctrl(Command) + 1: クイックフィックス&lt;br /&gt;
クイックフィックスは、汎用的に使える機能で、なんか不具合があったら押したら解決する方法を提示してくれたりします。自分が使う場合は、変数の定義の場合によく使います。&lt;br /&gt;
&lt;br /&gt;
まず右辺だけ書きます。今回はnew Intent();です。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj282JaBnuc4fOKaqRPVx9Dhmox9q73-Jvg0dP2SAEfZe8DB7X2w815B26xi0IWbPq8ueL2ta0v0G7foyeino6H3fbB0-bqIS8lof__lhQqLGRpyJpuVQgIH7bFWSP3lQJ-5ZYOIPvsANs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+23.18.37.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;64&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj282JaBnuc4fOKaqRPVx9Dhmox9q73-Jvg0dP2SAEfZe8DB7X2w815B26xi0IWbPq8ueL2ta0v0G7foyeino6H3fbB0-bqIS8lof__lhQqLGRpyJpuVQgIH7bFWSP3lQJ-5ZYOIPvsANs/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+23.18.37.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
その後、行にカーソルを合わせた状態でCtrl + 1を押します。&lt;br /&gt;
すると、クイックフィックスの候補が出てきます。新規ローカル変数を定義したいので、1つめを選択します。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO4i7m9iGs7V8viAO1fIqAr7XYygDPrEs7Dj1oqJqUTVW_SpMYzwWMLBadWHZwCrnkwakvO7rQ6HQSHaGBgad6hq2Ujj_vJQoVDsH1nHw9rVpOLDCEijgDmmttNFQrFrWcStonNWhZImU/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+23.18.52.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;114&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO4i7m9iGs7V8viAO1fIqAr7XYygDPrEs7Dj1oqJqUTVW_SpMYzwWMLBadWHZwCrnkwakvO7rQ6HQSHaGBgad6hq2Ujj_vJQoVDsH1nHw9rVpOLDCEijgDmmttNFQrFrWcStonNWhZImU/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+23.18.52.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;すると、左辺が保管されました。これを知ってから効率がだいぶあがりました。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiitRfFMfIEJdiu4yv0V8_gz8L2uwyqvfewoJw8TPfKyNgJisgf149WXs8BQPg0gsQ1894jShpuW5x4CcgqiBUisr3DTmSrrVIwYtpbYoQ8cZ1URUEty7mwPtefu1viBdeuyzSuTYQP0w0/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+23.19.05.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;51&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiitRfFMfIEJdiu4yv0V8_gz8L2uwyqvfewoJw8TPfKyNgJisgf149WXs8BQPg0gsQ1894jShpuW5x4CcgqiBUisr3DTmSrrVIwYtpbYoQ8cZ1URUEty7mwPtefu1viBdeuyzSuTYQP0w0/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+23.19.05.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
動作が重い分、使いこなせばかなり効率的にプログラミングや、レイアウトの記述ができるようになります。Eclipseを完全に使いこなす必要はないと思いますが、よく使う機能や便利な機能は知っておいたほうがいいと思ったので、紹介しました！&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/4353851940284376073/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/eclipse.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/4353851940284376073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/4353851940284376073'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/eclipse.html' title='Eclipseのショートカット集'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilR4UJpxwEEIJKIOTzmDsHfaw6JbuaH7M-kIwfewRY1ZHEPUFtusaKAh8UQdk8DDhv4ZEDz-7CKv_r4a4EBTAKYlqtiPFXuMWQWhu5PBoJmAyijvZ8agx3f2YPTp5tLqDBzqIwgSuvBVU/s72-c/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-10-04+22.33.06.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-9194597753732246502</id><published>2011-10-04T07:24:00.002+09:00</published><updated>2011-10-04T07:27:21.823+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="px)"/><category scheme="http://www.blogger.com/atom/ns#" term="sp"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="単位(dp"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Chapter10: 単位について(dp, sp, px)</title><content type='html'>今回はAndroidの単位についてです。&lt;br /&gt;
Webデザイナーの方は普段は単位はpxのみ気にしておけば、ほぼ大丈夫かと思いますが（印刷物はdpi気にしますが）Androidの場合は違います。&lt;br /&gt;
&lt;br /&gt;
理由は、端末によって解像度が違うためですね。&lt;br /&gt;
日本のAndroidで主流の解像度は以下の通りです。&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;800x480(hdpi)&lt;/li&gt;
&lt;li&gt;854x480(hdpi)&lt;/li&gt;
&lt;li&gt;960x640(hdpi)&lt;/li&gt;
&lt;/ul&gt;
また、主流ではないですが、以下の解像度の端末もあります。&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;480x320(mdpi)&lt;/li&gt;
&lt;li&gt;320x240(ldpi)&lt;/li&gt;
&lt;/ul&gt;
これだけあると、それぞれ専用のレイアウトを準備しないといけなさそうです。実際、準備する場合もあります。マルチスクリーンに関しては、別の機会に書こうと思います。今はシンプルに単位だけに注目します。&lt;br /&gt;
&lt;br /&gt;
Android Developersのサイトに、&lt;a href=&quot;http://developer.android.com/intl/ja/guide/practices/screens_support.html&quot;&gt;Supporting Multiple Screens&lt;/a&gt;という項目があります。まさに別の機会にとさっき書いたばかりの項目ですが、そこに、単位についても書いてあります。&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;dp(dip: density-independent pixel)&lt;/li&gt;
&lt;li&gt;sp(scaled pixel)&lt;/li&gt;
&lt;li&gt;px(pixel)&lt;/li&gt;
&lt;/ul&gt;
dp(dip)は、解像度に依存しないpixelです。&lt;br /&gt;
解像度に合わせて自動的にpixel変換が行われます。&lt;br /&gt;
&lt;br /&gt;
hdpiの端末は、240dpiです。&lt;br /&gt;
&lt;br /&gt;
240 / 160(基準値) = 1.5px = 1dp&lt;br /&gt;
&lt;br /&gt;
という計算になります。画面上で1.5pxは描けませんが、1dpは描けます。&lt;br /&gt;
&lt;br /&gt;
mdpiの端末は、160dpiです。&lt;br /&gt;
&lt;br /&gt;
160 / 160(基準値) = 1px = 1dp&lt;br /&gt;
&lt;br /&gt;
という計算になります。&lt;br /&gt;
&lt;br /&gt;
これを、px換算の解像度に当てはめると、&lt;br /&gt;
&lt;br /&gt;
800x480(hdpi)の端末だと、533dp x 320dpでした。&lt;br /&gt;
480x320(mdpi)の端末だと、480dp x 320dpでした。&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;なんとdp上だと、横の長さが&lt;b&gt;320dpで一致&lt;/b&gt;しましたね。
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
以下、800x480(hdpi)の端末です。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxtf9dZOOYI32_QyK2fxmLI0eJjseCQAqnP-xKj-k_zQZrzEVr-Uq_bKE0XvgF-5wdk2_zEWpzdEX6aawXPE_UsqvtiOIB5CMItwvnxTKwDjFtQPsmMt4hr5OkRrhzS2w_nNfR6XX0gQk/s1600/device-2011-10-03-173721.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxtf9dZOOYI32_QyK2fxmLI0eJjseCQAqnP-xKj-k_zQZrzEVr-Uq_bKE0XvgF-5wdk2_zEWpzdEX6aawXPE_UsqvtiOIB5CMItwvnxTKwDjFtQPsmMt4hr5OkRrhzS2w_nNfR6XX0gQk/s400/device-2011-10-03-173721.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
次は480x320(mdip)の端末(エミュレータ)です。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieaZh-CQuSl1x1eXv7b846ozdBKtg9ev6MnV5Am_AV6EBJw0pnNtnY0PfUYTgPaqy0cKIIRq5vJuU5JNKYvZST7zVt7u1s7-jCQ9OP5gKspz02Nv9z2PDQ6QfB4hXpePJwYU1gwuyf7XM/s1600/device-2011-10-03-173807.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieaZh-CQuSl1x1eXv7b846ozdBKtg9ev6MnV5Am_AV6EBJw0pnNtnY0PfUYTgPaqy0cKIIRq5vJuU5JNKYvZST7zVt7u1s7-jCQ9OP5gKspz02Nv9z2PDQ6QfB4hXpePJwYU1gwuyf7XM/s400/device-2011-10-03-173807.png&quot; width=&quot;266&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
16dpと書いている文字の大きさはどちらも同じですが、16pxと書いている文字の大きさは明らかに違います。特に、480x320の画面では、16dpも16pxも同じ大きさです。しかし、800x480の画面では違います。&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;16dpの文字の大きさはpxに換算すると&lt;b&gt;16dp x 1.5 = 24px&lt;/b&gt; の文字になるからです。&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
しかし、画面の幅自体は、どちらの端末も320dpです。画面の縦横比が違うので、ちょっと見づらいかもしれませんが、端末自体の大きさ（解像度でなく）が同じならば、文字のサイズは同じはずです。
&lt;br /&gt;
&lt;br /&gt;
dpを使えば、画面の解像度を意識する回数が減ります。dpを使っておけば、新しい解像度の端末が出ても、なんとなくちゃんと表示されて動いてくれるということも期待できます（モヤッとした言い回しですが）。
&lt;br /&gt;
&lt;br /&gt;
spという単位もありますが、spは文字の解像度設定に倣うという単位なので、基本的にレイアウトにではなく、フォントサイズ指定に使います。フォントサイズ指定ではdpではなくspを使いましょう。
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;

コードレビュー&lt;/h4&gt;
ではレイアウトのコードを見てみましょう。 Sample02プロジェクトの/res/layout/chapter10.xmlを開いてください。

&lt;br /&gt;
&lt;pre class=&quot;brush:xml; highlight:[17,23,29]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    android:orientation=&quot;vertical&quot;&amp;gt;
    &amp;lt;!-- 
        dp(dip)は、解像度に合わせてpxが変化する単位です。
        端末の解像度(dpi)に応じて、大きさが変化します。
        基本的にdp(dip)を使ってレイアウトを定義していきます。
        sp(scaled pixels)は主にフォント用の単位です。
        pxで定義する機会は、ほとんどないと言えますが意識する必要はあります。
     --&amp;gt;
    &amp;lt;!-- 普通はtextSizeにはdpは使いませんが、サンプルとして使ってます --&amp;gt;
    &amp;lt;TextView
        android:text=&quot;@string/chapter10_dp&quot;
        android:textSize=&quot;16dp&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot; /&amp;gt;
    &amp;lt;!-- 普通はtextSizeにはspを使うのでこっちのが正解 --&amp;gt;
    &amp;lt;TextView
        android:text=&quot;@string/chapter10_sp&quot;
        android:textSize=&quot;16sp&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot; /&amp;gt;
    &amp;lt;!-- 敢えてpxで指定してみた例。160dpi端末と240dpi端末で比較するといいです --&amp;gt;
    &amp;lt;TextView
        android:text=&quot;@string/chapter10_px&quot;
        android:textSize=&quot;16px&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot; /&amp;gt;
    &amp;lt;TextView
        android:text=&quot;@string/chapter10_description&quot;
        android:textSize=&quot;16sp&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot; /&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
textSizeに、各単位(16dp, 16sp, 16px)を指定しています。
解像度の違う端末で見てみると違いがわかりやすいです。なかなか準備できないので、エミュレータで比較してみるのがよいでしょう。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/9194597753732246502/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter10-dp-sp-px.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/9194597753732246502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/9194597753732246502'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter10-dp-sp-px.html' title='Chapter10: 単位について(dp, sp, px)'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxtf9dZOOYI32_QyK2fxmLI0eJjseCQAqnP-xKj-k_zQZrzEVr-Uq_bKE0XvgF-5wdk2_zEWpzdEX6aawXPE_UsqvtiOIB5CMItwvnxTKwDjFtQPsmMt4hr5OkRrhzS2w_nNfR6XX0gQk/s72-c/device-2011-10-03-173721.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-2074400297730005333</id><published>2011-10-04T04:14:00.000+09:00</published><updated>2011-10-04T04:14:43.734+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LinearLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Chapter09: marginとpaddingについて</title><content type='html'>今回はmarginとpaddingについてです。&lt;br /&gt;
marginとpaddingについては、感覚的にはCSSと同じです。ただ、border領域がありません。borderは別途background属性でdrawable(画像もしくは描画を表すxml)指定で表現することになります。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJxW5rVxO9RZ35SAxLUKSeXfI0cOxu_ixxf1InCHqJqyLpLfwMJzkpN8nGpK7WR6x-rKbvmunSY-5dy94Uw7RPXXQ52vrZWwYPbzSLXs9ZfpR3Krwhg5mb6MAaqbB2LjSC-6Ehd9OUySc/s1600/skitched-20111004-031711.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJxW5rVxO9RZ35SAxLUKSeXfI0cOxu_ixxf1InCHqJqyLpLfwMJzkpN8nGpK7WR6x-rKbvmunSY-5dy94Uw7RPXXQ52vrZWwYPbzSLXs9ZfpR3Krwhg5mb6MAaqbB2LjSC-6Ehd9OUySc/s320/skitched-20111004-031711.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;padding・・・要素から青枠までの領域（background属性が適用される範囲）&lt;/li&gt;
&lt;li&gt;margin・・・青枠から赤枠までの領域&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
marginは他要素からの距離になるので、Root要素（一番最初に定義されるLayoutなりView&lt;br /&gt;
なり）にmarginを定義しても、あまり意味がありません（定義できるけど動作が変？）。&lt;br /&gt;
&lt;br /&gt;
marginを定義するのは、何かしらの子要素に対してのみ、行いましょう。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
では、サンプルを見てみましょう。&lt;br /&gt;
Sample02アプリを起動して、メニューを押してchapter09を選んでください。&lt;br /&gt;
以下のような画面になります。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW_c2vEwb6IT4RfRq16WRchxjCm7tlhQSQ3tCHRKDwuPlfZBPIlgd_EHNtXu-3s3TTfAUgtTxz3BDKXK-NuSJR9iIkZ3HtC7JzzADG1R99bL7QNyCxzOv_SYJoQwQrDjjCM-kYV-Tk5Ew/s1600/device-2011-10-03-233312.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW_c2vEwb6IT4RfRq16WRchxjCm7tlhQSQ3tCHRKDwuPlfZBPIlgd_EHNtXu-3s3TTfAUgtTxz3BDKXK-NuSJR9iIkZ3HtC7JzzADG1R99bL7QNyCxzOv_SYJoQwQrDjjCM-kYV-Tk5Ew/s400/device-2011-10-03-233312.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
LinearLayoutのhorizontalを3つ準備して&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;marginのみ設定&lt;/li&gt;
&lt;li&gt;paddingのみ設定&lt;/li&gt;
&lt;li&gt;marginとpaddingの両方設定&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
を作ってみました。background属性がわかりやすいように、色を付けています。&lt;br /&gt;
パッと見た感じ、わかりにくいので、ちょっと解説用に矢印をつけたバージョンが以下です。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxbbOtAAwzxttQDAEOr0zxW7l0vMBGUEO5j5aVWFyYFoMZ14MHJ8F7owSY1eKqu8zUpH8llp3TiLE69ast0rGT4shEZ9kSuRAJOJ4Rj7TvuC6s8RIBo6duLVP0V3FToA6tnac_mz0exF4/s1600/device-2011-10-03-233312+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxbbOtAAwzxttQDAEOr0zxW7l0vMBGUEO5j5aVWFyYFoMZ14MHJ8F7owSY1eKqu8zUpH8llp3TiLE69ast0rGT4shEZ9kSuRAJOJ4Rj7TvuC6s8RIBo6duLVP0V3FToA6tnac_mz0exF4/s400/device-2011-10-03-233312+2.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
marginのみでTop, Leftなどを別々に指定みてみたところ、marginのみではその通りに反映されました。&lt;br /&gt;
&lt;br /&gt;
ところが、paddingのみで指定したところ、marginのときのようにはなりませんでした。ベースラインがpaddingTopの高いほうに合わせられました。オレンジ枠の部分はmarginでもpaddingでもありません。&lt;br /&gt;
&lt;br /&gt;
marginとpaddingの両方を指定したところ、思った通りの結果ですが、ベースラインはpaddingに合わせられ、marginも反映されました。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;


コードレビュー&lt;/h4&gt;
ではレイアウトのコードを見てみましょう。 Sample02プロジェクトの/res/layout/chapter09.xmlを開いてください。

&lt;br /&gt;
&lt;pre class=&quot;brush:xml; highlight:[44,45,51,52,71,72,73,74,80,81,82,83,100,101,102,103,110,111,112,113]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    android:orientation=&quot;vertical&quot;&amp;gt;
    &amp;lt;!-- 
        marginを指定する場合は、layout_marginを使います。
        個別に設定する場合は、
        layout_marginTop,
        layout_marginBottom,
        layout_marginRight,
        layout_marginLeft
        です。
        
        paddingを指定する場合は、paddingを使います。
        個別に設定する場合は、
        paddingTop,
        paddingBottom,
        paddingRight,
        paddingLeft
        です。
        
        CSSのブロック要素と同じく、コンテンツの周囲がpaddingで
        paddingの外側がmarginです。
        marginは、周囲の要素に対して有効なため、
        Root要素(ここでは2行目で定義しているLinearLayout)でmarginを
        定義しても有効ではありません。定義はできますが、動作が不確定ぽいです。
        Root以下の子要素で定義してください。
     --&amp;gt;
    &amp;lt;TextView
        android:text=&quot;@string/chapter09_margin&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot; /&amp;gt;
    &amp;lt;!-- marginのみ設定 --&amp;gt;
    &amp;lt;LinearLayout
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:orientation=&quot;horizontal&quot;&amp;gt;
        &amp;lt;TextView
            android:text=&quot;@string/app_name&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_marginTop=&quot;10dp&quot;
            android:layout_marginLeft=&quot;20dp&quot;
            android:background=&quot;#008000&quot; /&amp;gt;
        &amp;lt;TextView
            android:text=&quot;@string/app_name&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_marginTop=&quot;40dp&quot;
            android:layout_marginLeft=&quot;20dp&quot;
            android:background=&quot;#4b0082&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;!--
        paddingのみ設定
        より大きな数値でpaddingが設定されている要素にベースラインが合ってしまうようです。
     --&amp;gt;
    &amp;lt;TextView
        android:text=&quot;@string/chapter09_padding&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot; /&amp;gt;
    &amp;lt;LinearLayout
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:orientation=&quot;horizontal&quot;&amp;gt;
        &amp;lt;TextView
            android:text=&quot;@string/app_name&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:paddingTop=&quot;10dp&quot;
            android:paddingLeft=&quot;20dp&quot;
            android:paddingBottom=&quot;10dp&quot;
            android:paddingRight=&quot;20dp&quot;
            android:background=&quot;#008000&quot; /&amp;gt;
        &amp;lt;TextView
            android:text=&quot;@string/app_name&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:paddingTop=&quot;40dp&quot;
            android:paddingLeft=&quot;20dp&quot;
            android:paddingBottom=&quot;20dp&quot;
            android:paddingRight=&quot;40dp&quot;
            android:background=&quot;#4b0082&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;TextView
        android:text=&quot;@string/chapter09_margin_padding&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot; /&amp;gt;
    &amp;lt;!-- marginとpaddingを設定 --&amp;gt;
    &amp;lt;LinearLayout
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:orientation=&quot;horizontal&quot;&amp;gt;
        &amp;lt;TextView
            android:text=&quot;@string/app_name&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_margin=&quot;10dp&quot;
            android:paddingTop=&quot;10dp&quot;
            android:paddingLeft=&quot;20dp&quot;
            android:paddingBottom=&quot;10dp&quot;
            android:paddingRight=&quot;20dp&quot;
            android:background=&quot;#008000&quot; /&amp;gt;
        &amp;lt;TextView
            android:text=&quot;@string/app_name&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_margin=&quot;10dp&quot;
            android:paddingTop=&quot;40dp&quot;
            android:paddingLeft=&quot;20dp&quot;
            android:paddingBottom=&quot;20dp&quot;
            android:paddingRight=&quot;40dp&quot;
            android:background=&quot;#4b0082&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
marginは以下のようにして指定します。
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;layout_margin・・・上下左右すべて同じ値を指定したい場合&lt;/li&gt;
&lt;li&gt;layout_marginTop・・・上のみ指定&lt;/li&gt;
&lt;li&gt;layout_marginBottom・・・下のみ指定&lt;/li&gt;
&lt;li&gt;layout_marginLeft・・・左のみ指定&lt;/li&gt;
&lt;li&gt;layout_marginRight・・・右のみ指定&lt;/li&gt;
&lt;/ul&gt;
marginの場合、layout_という接頭辞が付きます。個別に設定する機会のほうが多いかと思います。これはCSSのmarginの指定と同じですね。

&lt;br /&gt;
&lt;br /&gt;
paddingは以下のようにして設定します。&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;padding・・・上下左右すべて同じ値を指定したい場合&lt;/li&gt;
&lt;li&gt;paddingTop・・・上のみ指定&lt;/li&gt;
&lt;li&gt;paddingBottom・・・下のみ指定&lt;/li&gt;
&lt;li&gt;paddingLeft・・・左のみ指定&lt;/li&gt;
&lt;li&gt;paddingRight・・・右のみ指定&lt;/li&gt;
&lt;/ul&gt;
paddingの場合はpaddingなんちゃらです。これもCSSのpaddingと同じような設定なので、特に違和感ないと思います。&lt;br /&gt;
&lt;br /&gt;
「いやいや！marginとpaddingの概念はわかったけども、そこに指定する値はどうやって算出するのさ！そもそもdpって何よ！？」って思ってる人が多いと思います。&lt;br /&gt;
なので、次はAndroidのレイアウトにおける単位を取り扱います。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/2074400297730005333/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter09-marginpadding.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/2074400297730005333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/2074400297730005333'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter09-marginpadding.html' title='Chapter09: marginとpaddingについて'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJxW5rVxO9RZ35SAxLUKSeXfI0cOxu_ixxf1InCHqJqyLpLfwMJzkpN8nGpK7WR6x-rKbvmunSY-5dy94Uw7RPXXQ52vrZWwYPbzSLXs9ZfpR3Krwhg5mb6MAaqbB2LjSC-6Ehd9OUySc/s72-c/skitched-20111004-031711.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-6186375360705199879</id><published>2011-10-04T02:34:00.000+09:00</published><updated>2011-10-04T02:34:26.218+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="RelativeLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Chapter08: Viewを重ねる</title><content type='html'>今回は「Viewを重ねる」です。&lt;br /&gt;
Viewを重ねるというのは、画像の上に文字を表示したりする場合などが考えられます。私がよく使っている方法ですが、RelativeLayoutの下にImageViewとTextViewを入れ、margin, paddingをいじって場所決めをして重ねています（margin, paddingについてはChapter09で取り上げます）。&lt;br /&gt;
&lt;br /&gt;
LinearLayoutでは基本的にViewが重なり合うということはないので、RelativeLayoutを使います。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
では、サンプルを見てみましょう。&lt;br /&gt;
&amp;nbsp;Sample02アプリを起動して、メニューを押してchapter08を選んでください。&lt;br /&gt;
以下のような画面になります。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgleO-ey8yobT3xf2CNEySoJu-mu1Vr56CA6aA_smLV4lrYX5L-Rdr262tr83w6rgHtP5nLun9mjT6Lo0MyXfk6JOhyphenhyphen_lGYjRFExe7aM-4uqlKLlnvQ8qhSIn3FFnUh8lhyvyHM-sMUte0/s1600/device-2011-10-03-233337.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgleO-ey8yobT3xf2CNEySoJu-mu1Vr56CA6aA_smLV4lrYX5L-Rdr262tr83w6rgHtP5nLun9mjT6Lo0MyXfk6JOhyphenhyphen_lGYjRFExe7aM-4uqlKLlnvQ8qhSIn3FFnUh8lhyvyHM-sMUte0/s400/device-2011-10-03-233337.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Chapter07とどこが違うねん！という感じですが、よく見ると、右上にSample02の文字があります。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVxJzPJg-s-dGNJdV9-Jaxjth3eo14eY0JUIVYRIbCZOfTRuCuNt81XeNrOOSE568oP0z6KhQbvEpNjHB9eg43uv1UygixhukBPez-iPM2iNJ4g4NAFz1m562c6JZ0EhHCbECi8bHYsU0/s1600/device-2011-10-03-233337+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVxJzPJg-s-dGNJdV9-Jaxjth3eo14eY0JUIVYRIbCZOfTRuCuNt81XeNrOOSE568oP0z6KhQbvEpNjHB9eg43uv1UygixhukBPez-iPM2iNJ4g4NAFz1m562c6JZ0EhHCbECi8bHYsU0/s400/device-2011-10-03-233337+2.png&quot; style=&quot;cursor: move;&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Sample02という文字列はlayout_alignParentRight=trueが指定されています。これで親要素のRelativeLayoutに対して右寄せの位置に表示されます。しかしバリスタの画像のサイズが ちょっと小さかったので、重なってないように見えたので、ついでだからlayout_margin指定をして画像の上にもってきてみました。&lt;br /&gt;
&lt;br /&gt;
親要素に対して相対的に配置すれば、View同士を重ねることができるわけです。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;

コードレビュー&lt;/h4&gt;
ではレイアウトのコードを見てみましょう。 Sample02プロジェクトの/res/layout/chapter08.xmlを開いてください。 

&lt;br /&gt;
&lt;pre class=&quot;brush: xml; highlight:[23,24,25]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;RelativeLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&amp;gt;
    &amp;lt;!-- 
        親要素(RelativeLayout)に対して、子要素を相対的に配置します。
        親要素に対して相対的に配置すれば、Viewを重ねることができます。
        今回はTextViewをRelativeLayoutに対して右寄せにして、
        layout_margin***を指定することで、ImageViewの上に重ねました。
     --&amp;gt;
    &amp;lt;ImageView
        android:src=&quot;@drawable/barista&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:layout_centerInParent=&quot;true&quot;
        android:scaleType=&quot;fitCenter&quot;
        android:adjustViewBounds=&quot;true&quot; /&amp;gt;
    &amp;lt;TextView
        android:text=&quot;@string/app_name&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:layout_alignParentRight=&quot;true&quot;
        android:layout_marginTop=&quot;40dp&quot;
        android:layout_marginRight=&quot;40dp&quot; /&amp;gt;
&amp;lt;/RelativeLayout&amp;gt;
&lt;/pre&gt;
TextViewに、layout_alignParentRight=trueを指定して、親要素のRelativeLayoutに対して右寄せにしています(23行目)。&lt;br /&gt;
その後、24行目、25行目でmarginの指定を行っています。親要素のRelativeLayoutからのマージンになっています。重ねるだけならば、そこまで難しいことはありません。複雑なレイアウトも、分解していけばこのレイアウトのような形で、RelativeLayout内で重ねるなどが多いんじゃないかなと思います(あくまで自分の経験の中でですが)</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/6186375360705199879/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter08-view.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/6186375360705199879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/6186375360705199879'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter08-view.html' title='Chapter08: Viewを重ねる'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgleO-ey8yobT3xf2CNEySoJu-mu1Vr56CA6aA_smLV4lrYX5L-Rdr262tr83w6rgHtP5nLun9mjT6Lo0MyXfk6JOhyphenhyphen_lGYjRFExe7aM-4uqlKLlnvQ8qhSIn3FFnUh8lhyvyHM-sMUte0/s72-c/device-2011-10-03-233337.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-3143699026277375856</id><published>2011-10-04T00:52:00.001+09:00</published><updated>2011-10-04T00:55:05.107+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="RelativeLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Chapter07: 画像を中央表示する</title><content type='html'>さて、Sample02プロジェクトを開始します。&lt;br /&gt;
まだインポートをしていない方は、「&lt;a href=&quot;http://chariderpato.blogspot.com/2011/10/sample02.html&quot;&gt;Sample02プロジェクトを公開しました&lt;/a&gt;」より、Eclipseへのインポートをお願いします。

今回は、レイアウトの中央に画像を表示する方法です。
まぁこれも、ぴんとくる人はくると思いますが、RelativeLayoutのlayout_centerInParentを使います。
Chapter02で使っている、中央に文字を表示していたやつです。

&lt;br /&gt;
&lt;br /&gt;
では、サンプルを見てみましょう。&lt;br /&gt;
Sample02アプリを起動してください。&lt;br /&gt;
以下のような画面になります。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj5YS3cryu9AKGTaLTSy9DUzoNIa405K8eLz2V5Ba9HGi0bTjqqJ3BX4c1w3FyeYLgZ-VNZMl9fHLrbF9DZ-gBymHJp_4x65YWzYZNJmFKfMLh4UwinBgroeEuDFcbA9aSdWqVu_yP2so/s1600/device-2011-10-03-233327.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj5YS3cryu9AKGTaLTSy9DUzoNIa405K8eLz2V5Ba9HGi0bTjqqJ3BX4c1w3FyeYLgZ-VNZMl9fHLrbF9DZ-gBymHJp_4x65YWzYZNJmFKfMLh4UwinBgroeEuDFcbA9aSdWqVu_yP2so/s400/device-2011-10-03-233327.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
画像はネスカフェのバリスタです。&lt;br /&gt;
Androidで画像を扱う場合は、ImageViewを使います（ゲームなどでは、SurfaceView）。普段はImageViewを使うと思っていて大丈夫です。

&lt;br /&gt;
&lt;h4&gt;

コードレビュー&lt;/h4&gt;
ではレイアウトのコードを見てみましょう。
Sample02プロジェクトの/res/layout/chapter07.xmlを開いてください。

&lt;br /&gt;
&lt;pre class=&quot;brush: xml; highlight:[20,21,22]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;RelativeLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&amp;gt;
    &amp;lt;!-- 
        layout_centerInParent=trueにしているので、
        画像が領域の中央に配置されます。
        ImageViewのscaleTypeをfitCenterにすることで、
        領域に合わせて自動でリサイズされます。
        scaleTypeは色々あるので、時間があれば他の値も試してみましょう。
        また、解像度の大きい画像を使うとメモリを消費しやすくてアプリが
        強制終了しやすくなります。
        なるべく画面の解像度に近いサイズにしましょう。
     --&amp;gt;
    &amp;lt;ImageView 
        android:src=&quot;@drawable/barista&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:layout_centerInParent=&quot;true&quot;
        android:scaleType=&quot;fitCenter&quot;
        android:adjustViewBounds=&quot;true&quot;
    /&amp;gt;
&amp;lt;/RelativeLayout&amp;gt;
&lt;/pre&gt;
RelativeLayoutが親要素です。その子要素のImageViewに、layout_centerInParentを指定しています(20行目)。&lt;br /&gt;
&lt;br /&gt;
21行目で、scaleTypeという指定を行っています。fitCenterにしておくと、大きな画像の場合、表示領域の大きさ(layout_width, layout_height)に自動的に縮小されます。このscaleTypeもまた色々種類があるのですが、ほぼfitCenterしか使わないんじゃないかと思うので説明は省略します。&lt;br /&gt;
&lt;br /&gt;
22行目のadjustViewBoundsは、描画の縦横比を維持するかどうかです。ImageViewのlayout_width, layout_heightの値が画像の縦横比の影響を受けて変化する、という認識なのですが、違うかもしれません（汗。レイアウトを静的に作るときには、trueにしておけばいいと思っています。&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;外部リンクになりますが、&lt;a href=&quot;http://wikiwiki.jp/android/?UI%A5%B3%A5%F3%A5%DD%A1%BC%A5%CD%A5%F3%A5%C8%2FImageView&quot;&gt;Android Wiki UIコンポーネント / ImageView&lt;/a&gt; を見たら参考になります。&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;スマートフォンはメモリが少ないですし、アプリ毎にメモリ割り当て上限が決まっているので、サイズの大きな画像を読み込ませるとOut Of Memoryという例外が発生してアプリが落ちます。なるべく、端末の解像度に近い画像を準備するようにしましょう（マルチ解像度については別のところで取り上げるのでそれまで待っててください）。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/3143699026277375856/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter07.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/3143699026277375856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/3143699026277375856'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter07.html' title='Chapter07: 画像を中央表示する'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj5YS3cryu9AKGTaLTSy9DUzoNIa405K8eLz2V5Ba9HGi0bTjqqJ3BX4c1w3FyeYLgZ-VNZMl9fHLrbF9DZ-gBymHJp_4x65YWzYZNJmFKfMLh4UwinBgroeEuDFcbA9aSdWqVu_yP2so/s72-c/device-2011-10-03-233327.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-1315349148749858431</id><published>2011-10-03T23:58:00.000+09:00</published><updated>2011-10-03T23:58:39.334+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Sample02プロジェクトを公開しました</title><content type='html'>前回までで、Sample01のプロジェクトの内容が終わりました。&lt;br /&gt;
次のプロジェクトを準備してあるので、Sample02プロジェクトをダウンロードしてインポートしてください。やり方は、&lt;a href=&quot;http://chariderpato.blogspot.com/2011/09/eclipsezip.html&quot;&gt;Eclipseでプロジェクトをインポートする(zipのまま)&lt;/a&gt;です。ダウンロードするURLの部分だけ、読み替えてください。よろしくお願いします。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://github.com/patorash/AndroidLayoutXmlStudy-Sample02&quot;&gt;Sample02プロジェクトへのリンク(github)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Sample02プロジェクトで取り扱う内容は、以下の通りです。&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;(Chapter07)画像を中央配置する(Chapter07)&lt;/li&gt;
&lt;li&gt;(Chapter08)Viewを重ねて表示する&lt;/li&gt;
&lt;li&gt;(Chapter09)margin, paddingについて&lt;/li&gt;
&lt;li&gt;(Chapter10)Androidでの単位について(dp, sp, pxなど)&lt;/li&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/1315349148749858431/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/sample02.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/1315349148749858431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/1315349148749858431'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/sample02.html' title='Sample02プロジェクトを公開しました'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-151218823635658829</id><published>2011-10-03T01:42:00.000+09:00</published><updated>2011-10-03T01:42:53.262+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LinearLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Chapter06: フッターを作る方法</title><content type='html'>今回はフッターを作る方法です。&lt;br /&gt;
サイトを作っていても、全画面表示でフッターを一番下に表示する方法など、結構面倒ですが、Androidのレイアウトではそんなに難しいことではありません。方法はまぁ色々とありますが、感のいい人ならひょっとしたら気づいているかもしれません。&lt;br /&gt;
&lt;br /&gt;
今回は、layout_weightを使います。&lt;br /&gt;
&lt;br /&gt;
layout_weightといえば、Chapter03とChapter04で使いましたね。&lt;br /&gt;
&lt;br /&gt;
では、サンプルを見てみましょう。&lt;br /&gt;
サンプルアプリでメニューを押して、chapter06を選択してください。&lt;br /&gt;
以下のような画面になります。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuwadDcMLW9clsV1DhC5ZSXfZP0vjSCksQPQlBE8XYT1JGl0Q04TP5k9Tr2AqIbYLF3S-oi9GeVOxFaOtrsKSmGIniuTbDNYfaC9VdFm8IQWulTsPQJegBihX_h4x9lYbOl83QA_aI4mY/s1600/device-2011-10-03-010420.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuwadDcMLW9clsV1DhC5ZSXfZP0vjSCksQPQlBE8XYT1JGl0Q04TP5k9Tr2AqIbYLF3S-oi9GeVOxFaOtrsKSmGIniuTbDNYfaC9VdFm8IQWulTsPQJegBihX_h4x9lYbOl83QA_aI4mY/s400/device-2011-10-03-010420.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
フッター側に特別な指定を行うのではなく、上のViewにlayout_weight属性をつけます。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4oLWbn-U62m6sN89XWGf3QCcllHPGpbaeJ5IB5DZ3JVihaR2c-hDnui1Y6VTyAul-6AO0I7ztnsBM_Sj0AbIFDHYq1yTL3A7NdIbjb9yILtcmV9ysddLhwbs5MRccnI7NJ_yuW4Ij4NY/s1600/device-2011-10-03-010420+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4oLWbn-U62m6sN89XWGf3QCcllHPGpbaeJ5IB5DZ3JVihaR2c-hDnui1Y6VTyAul-6AO0I7ztnsBM_Sj0AbIFDHYq1yTL3A7NdIbjb9yILtcmV9ysddLhwbs5MRccnI7NJ_yuW4Ij4NY/s400/device-2011-10-03-010420+2.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;h4&gt;コードレビュー&lt;/h4&gt;
ではレイアウトのコードを見てみましょう。&lt;br /&gt;
Sample01プロジェクトの/res/layout/chapter06.xmlを開いてください。

&lt;pre class=&quot;brush: xml; highlight=[10]&quot;&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&amp;gt;
    &amp;lt;ScrollView
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;0dp&quot;
        android:layout_weight=&quot;1&quot;&amp;gt;
        &amp;gt;
        &amp;lt;LinearLayout
            android:orientation=&quot;vertical&quot;
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;fill_parent&quot;&amp;gt;
            &amp;lt;TextView
                android:text=&quot;@string/chapter06_long_text&quot;
                android:layout_width=&quot;fill_parent&quot;
                android:layout_height=&quot;fill_parent&quot; /&amp;gt;
        &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;/ScrollView&amp;gt;
    &amp;lt;LinearLayout
        android:orientation=&quot;vertical&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;&amp;gt;
        &amp;lt;Button
            android:text=&quot;@string/chapter06_button&quot;
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;wrap_content&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
ScrollViewにlayout_weight=1をつけています。これにより、同じ階層にあるLinearLayoutは子要素が使っている領域分（ここではボタン）のみ使用することになります。こんな感じで、フッターは簡単に実装できます。
ここでのフッターは常に画面に表示されているフッターになりますが、そうでないフッター（リストの一番下にあるフッターなど）は、またそれ用の実装方法があります。

リストのフッターの実装方法は、ListViewのFooterViewを追加するという方法でJavaでの記述が必要になるので、これ以上はここでは言及しません。
トップ画面でフッターをつけてくれと言われたら、こんな方法がある程度に覚えておいてください。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/151218823635658829/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter06.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/151218823635658829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/151218823635658829'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter06.html' title='Chapter06: フッターを作る方法'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuwadDcMLW9clsV1DhC5ZSXfZP0vjSCksQPQlBE8XYT1JGl0Q04TP5k9Tr2AqIbYLF3S-oi9GeVOxFaOtrsKSmGIniuTbDNYfaC9VdFm8IQWulTsPQJegBihX_h4x9lYbOl83QA_aI4mY/s72-c/device-2011-10-03-010420.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-3499806140734303938</id><published>2011-10-02T20:08:00.000+09:00</published><updated>2011-10-02T20:21:18.269+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LinearLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Chapter05: スクロールするViewの配置</title><content type='html'>今回はスクロールするViewについてです。&lt;br /&gt;
LinearLayoutの中には、いくらでも子要素を入れることができますが、画面内におさまらないくらいに子要素を追加すると、画面からはみ出たままで、画面はスクロールすることができません。&lt;br /&gt;
&lt;br /&gt;
そういうときには、ScrollViewを使います。&lt;br /&gt;
&lt;br /&gt;
よく見かけるリスト化されたView(ListView)や、グリッド表示のView(GridView)は、もともとスクロールするための機能を内包しているので、この処理は必要ありません。長いフォームなどの場合や、長い文章を読ませたい場合などに使うとよいでしょう。&lt;br /&gt;
&lt;br /&gt;
画面をスクロールさせるためのViewですが、2種類あります。&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;ScrollView(縦方向のスクロールを担当)&lt;/li&gt;
&lt;li&gt;HorizontalScrollView(横方向のスクロールを担当)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
ScrollViewという名前だと縦横のどちらも使えそうで、縦方向のスクロールViewがVerticalScrollViewとかじゃないのが、何故かという話がちょろっとネットで話題になってたこともありました。ちょっと横道にそれてしまいましたが、HorizontalScrollViewはボタンの配置とかで使うことがあるので、横方向の場合は違う！ということくらいは覚えておきましょう。&lt;br /&gt;
&lt;br /&gt;
では、サンプルを見てみましょう。&lt;br /&gt;
サンプルアプリでメニューを押して、chapter05を選択してください。&lt;br /&gt;
以下のような画面なります。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-FeuD2JEF9SD5wMpt3LrXWQYa0e54riBS8rhhw8FF2G0mOkpPnd9iS-4Q_d4xIClPpKFMRh-0rfjTA4Xdm2o3P23m0H61WAH8qxaPd1mblew58ktXVdtFj2qk179rysQ3CI30AJtYLI/s1600/device-2011-10-02-191859.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-FeuD2JEF9SD5wMpt3LrXWQYa0e54riBS8rhhw8FF2G0mOkpPnd9iS-4Q_d4xIClPpKFMRh-0rfjTA4Xdm2o3P23m0H61WAH8qxaPd1mblew58ktXVdtFj2qk179rysQ3CI30AJtYLI/s320/device-2011-10-02-191859.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
ここぞとばかりにTextViewをコピーしまくってみました。下のほうが薄らグラデーションがかかってるのがわかりますでしょうか？続きがあるよというのを見た目的にわかるようにするため、ScrollViewにはそのような機能があります。この範囲の長さなども変更可能です（ここでは取り上げない）
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh18PCIgFM6uCMal-n3PHxH_jrTvbyohyphenhyphenKNZYIw26UjS19OBhU0oUkaobsBJLGcieITcT8HK19WohivOxnZqrUlEHXW0uAAsXqV5p3t3goIR3B6UkzzaXZFERqV5YbUNVBYTTmB-77rZlM/s1600/device-2011-10-02-191920.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh18PCIgFM6uCMal-n3PHxH_jrTvbyohyphenhyphenKNZYIw26UjS19OBhU0oUkaobsBJLGcieITcT8HK19WohivOxnZqrUlEHXW0uAAsXqV5p3t3goIR3B6UkzzaXZFERqV5YbUNVBYTTmB-77rZlM/s320/device-2011-10-02-191920.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;

コードレビュー&lt;/h4&gt;
では、レイアウトのソースコードを見てみましょう。Sample01プロジェクトの/res/layout/chapter05.xmlを開いてください。

&lt;br /&gt;
&lt;pre class=&quot;brush: xml; highlight:[]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;ScrollView
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&amp;gt;
    &amp;lt;!-- 
        この例のように、レイアウトに必ずViewが入ってなければいけないわけではありません。
        縦方向のスクロールが欲しい場合は、ScrollViewを使います。
        横方向のスクロールが欲しい場合は、HorizontalScrollViewを使います。
        今回は、ScrollViewのサンプルです。
        ScrollViewは、直近の子要素として、1つのViewしか受け付けません。
        ですので、ScrollViewの下には、LinearLayoutなどを配置し、
        その下にスクロールされるであろう要素を並べます。
        
        また、リスト表示をする場合はListViewなどを使いますが、ListView系は
        すでにScrollViewを梱包しているので、ScrollViewの下にListViewを入れる必要は
        ありません。
        
        あくまで、長いフォームなどを作る場合などに、ScrollViewを使うとよいでしょう。
     --&amp;gt;
    &amp;lt;LinearLayout
        android:orientation=&quot;vertical&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;fill_parent&quot;&amp;gt;
        &amp;lt;!-- 手抜きでTextViewをたくさんコピーしています --&amp;gt;
        &amp;lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/chapter01_linearlayout_vertical&quot; /&amp;gt;
        &amp;lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/chapter01_linearlayout_vertical&quot; /&amp;gt;
        &amp;lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/chapter01_linearlayout_vertical&quot; /&amp;gt;
（長いので省略）
    &amp;lt;/LinearLayout&amp;gt;
&amp;lt;/ScrollView&amp;gt;
&lt;/pre&gt;
ScrollViewの子要素には、1つしか置くことができません。2つ以上の要素を置くとエラーでアプリが落ちます。スクロールバーを表示する対象が1つだけだからなのでしょう。&lt;br /&gt;
なので、ScrollViewの子要素にはLinearLayoutもしくはRelativeLayoutなどを配置するとよいでしょう。そのレイアウトの下にはいくらでも子要素を配置できます。&lt;br /&gt;
&lt;br /&gt;
LinearLayoutの中には大量にTextViewを入れています（長いので省略していますが）。&lt;br /&gt;
ScrollViewを使えば、後はレイアウトの配置は同じなので、特に困ることはないと思います。しかし、ScrollViewの中にScrollViewを入れたりするとよくわからない感じになることがあるので、そういう使い方はなるべく避けましょう。&lt;br /&gt;
&lt;br /&gt;
最後がアバウトな書き方になってすみません！</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/3499806140734303938/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter05-view.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/3499806140734303938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/3499806140734303938'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter05-view.html' title='Chapter05: スクロールするViewの配置'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-FeuD2JEF9SD5wMpt3LrXWQYa0e54riBS8rhhw8FF2G0mOkpPnd9iS-4Q_d4xIClPpKFMRh-0rfjTA4Xdm2o3P23m0H61WAH8qxaPd1mblew58ktXVdtFj2qk179rysQ3CI30AJtYLI/s72-c/device-2011-10-02-191859.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-1673423710757987698</id><published>2011-10-01T01:29:00.000+09:00</published><updated>2011-10-01T01:29:07.228+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LinearLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Chapter04: 縦方向に均等配置</title><content type='html'>前回は、横方向に均等配置でした。今回は、縦方向に均等配置です。&lt;br /&gt;
内容はどう違うの？という話ですが、ほぼ同じです。&lt;br /&gt;
なので、今回はサラッと流します。&lt;br /&gt;
&lt;br /&gt;
注目すべき点は、同じくlayout_weightです。&lt;br /&gt;
&lt;br /&gt;
では、サンプルを見てみましょう。&lt;br /&gt;
サンプルアプリで、メニューを押して、chapter04を選択してください。&lt;br /&gt;
以下のような画面になります。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqNmrvjgulJnJUihR93ItuEq-BUP6Q-xw32qXB2mfF5jHO7e0IZoBZgVoSFkD2A9EIBY2CwYR1QaByWEYIEVgsaeDnApGYMruypxY5qk6eId9OF7INhoSjvzDYTN27DbbrDQWWZzzsGr8/s1600/device-2011-10-01-011032.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqNmrvjgulJnJUihR93ItuEq-BUP6Q-xw32qXB2mfF5jHO7e0IZoBZgVoSFkD2A9EIBY2CwYR1QaByWEYIEVgsaeDnApGYMruypxY5qk6eId9OF7INhoSjvzDYTN27DbbrDQWWZzzsGr8/s320/device-2011-10-01-011032.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
この画面は、LinearLayoutで横方向配置を指定した後に、さらにLinearLayoutを3つ入れて、それぞれは縦方向配置の設定をしています。&lt;br /&gt;
layout_weightは、レイアウトの重みづけで、高ければ高いほど重要度が増すとChapter03で説明しました。このレイアウトも、Chapter03の縦版なので、同様の設定になっています。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifjf82mx7CVR7pTWigf96Ey_T13JdvePrTTfK11yAt6f6JvaR_IGnOhcdWGtXdbFM6YDwAha6Fc4V6qp_XmSGpFo3rB5fPudJU7OOCjzYtgPEbKBrzOnk6BQEKEHFoH9p_y7rNjyRyitU/s1600/device-2011-10-01-011032+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifjf82mx7CVR7pTWigf96Ey_T13JdvePrTTfK11yAt6f6JvaR_IGnOhcdWGtXdbFM6YDwAha6Fc4V6qp_XmSGpFo3rB5fPudJU7OOCjzYtgPEbKBrzOnk6BQEKEHFoH9p_y7rNjyRyitU/s320/device-2011-10-01-011032+2.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;コードレビュー&lt;/h4&gt;
では、レイアウトのソースコードを見てみましょう。Sample01プロジェクトの/res/layout/chapter04.xmlを開いてください。

&lt;pre class=&quot;brush: xml; highlight: [22,23,28,29,34,35,58,59,71,72,77,78,83,84]&quot;&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;horizontal&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&amp;gt;
    &amp;lt;!-- 
        縦方向均等配置をするため、親要素のLinearLayoutのorientationをverticalに設定します。
        ここでは、layout_weightが肝です。指定された方向に対してウェイトが重い分だけ、拡がります。 
        デフォルトは0なので、1つの要素でも1を与えるとそれが残りの領域を占拠します。
        また、均等配置する方向が横の場合、layout_widthに有効な値をいれても無駄になるので0dpを入れます。
     --&amp;gt;
    &amp;lt;!-- 均等配置
         全ての要素にlayout_weight=&quot;1&quot;を設定 --&amp;gt;
    &amp;lt;LinearLayout
        android:orientation=&quot;vertical&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;fill_parent&quot;&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button1&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;0dp&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter04_button1&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button2&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;0dp&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter04_button2&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button3&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;0dp&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter04_button3&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;!-- 1つの要素だけlayout_weightを設定
         ただし、layout_weightが設定されてないボタンが表示されるように、
         layout_height=&quot;wrap_content&quot;にしてます。 --&amp;gt;
    &amp;lt;LinearLayout
        android:orientation=&quot;vertical&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;fill_parent&quot;&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button4&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/chapter04_button4&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button5&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/chapter04_button5&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button6&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;0dp&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter04_button6&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;!-- 全ての要素にlayout_weightを設定
         但し、button9のみweightを2にしている --&amp;gt;
    &amp;lt;LinearLayout
        android:orientation=&quot;vertical&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;fill_parent&quot;&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button7&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;0dp&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter04_button7&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button8&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;0dp&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter04_button8&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button9&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;0dp&quot;
            android:layout_weight=&quot;2&quot;
            android:text=&quot;@string/chapter04_button9&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;

※以降、Chapter03と同じ言い回しになりますので、無視したい人は無視してください。&lt;br /&gt;

&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;b&gt;注目するべきは、layout_heightの値を0dpにしているところです&lt;/b&gt;&lt;/span&gt;。
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;layout_heightに0dp以外の有効な値を入れると、無駄に解析が入ってしまって非効率だからです&lt;/span&gt;&lt;/b&gt;。モバイル端末は基本的に非力だしバッテリー持たせる必要があるので、無駄な処理は極力削ります。それはプログラムだけでなく、レイアウトのXMLでも言えるのです。&lt;br /&gt;
&lt;br /&gt;
layout_heightの効能は、LinearLayoutのorientationの方向で意味づけが決まるので、verticalの場合は、縦方向に効きます。なので、layout_height=&quot;0dp&quot;なわけです。&lt;br /&gt;
&lt;br /&gt;
均等配置がlayout_weightを指定するだけで簡単にできることがわかってもらえたかと思います。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/1673423710757987698/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter04.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/1673423710757987698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/1673423710757987698'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter04.html' title='Chapter04: 縦方向に均等配置'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqNmrvjgulJnJUihR93ItuEq-BUP6Q-xw32qXB2mfF5jHO7e0IZoBZgVoSFkD2A9EIBY2CwYR1QaByWEYIEVgsaeDnApGYMruypxY5qk6eId9OF7INhoSjvzDYTN27DbbrDQWWZzzsGr8/s72-c/device-2011-10-01-011032.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-8398014526129312264</id><published>2011-10-01T00:11:00.001+09:00</published><updated>2011-10-01T00:45:23.990+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LinearLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Chapter03: 横方向に均等配置</title><content type='html'>LinearLayoutとRelativeLayoutの説明が終わりましたので、ここからはLinearLayoutを使った具体的なレイアウトの方法に入っていきます。とはいってもまだ基本編です。&lt;br /&gt;
&lt;br /&gt;
アプリを使っている人はよく見かけていると思うのですが、ボタンなどの均等配置はどうやるのだろうか？と。CSSならば、もともと決まっているwidthの値を3で割って…などだと思うのですが、Androidでは、もっと簡単な方法が準備されています。&lt;br /&gt;
&lt;br /&gt;
それはlayout_weightという属性です。&lt;br /&gt;
&lt;br /&gt;
では、サンプルを見てみましょう。&lt;br /&gt;
サンプルアプリで、メニューを押して、chapter03を選択してください。&lt;br /&gt;
以下のような画面になります。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKQBc-Q546bqPgmDUVkIE5n0oT6ic3xH9bmP2drmpnprpHvk7B3ZVO4TjPztsJfwA4RFDPm6ABYOJWbYadoo_mnF-PiUeGq2zyrWA-SmhiQnDmhXKgx6Gso5DkbQ6gvn5shBQ_v5UqikU/s1600/device-2011-09-30-234040.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKQBc-Q546bqPgmDUVkIE5n0oT6ic3xH9bmP2drmpnprpHvk7B3ZVO4TjPztsJfwA4RFDPm6ABYOJWbYadoo_mnF-PiUeGq2zyrWA-SmhiQnDmhXKgx6Gso5DkbQ6gvn5shBQ_v5UqikU/s400/device-2011-09-30-234040.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
この画面は、LinearLayoutで縦方向配置の指定をした後に、さらにLinearLayoutを3つ入れて、それぞれは横方向配置の設定をしています。&lt;br /&gt;
&lt;br /&gt;
先ほど言った、layout_weightという属性は、レイアウトの重みづけに当たります。高ければ高いほど、重要度が増します。下の画像の赤枠で囲まれている部分のように均等に配置したい場合は、layout_weight全て1にします。&lt;br /&gt;
&lt;br /&gt;
他の場合も見てもらおうと思い、設定してありますが、2行目のボタンの部分は、ボタン4、ボタン5にはlayout_weightを指定していません。そして、ボタン6のみ、1を指定しています。すると、ボタン6が一番重要ということになり、残された領域全部を使います。&lt;br /&gt;
&lt;br /&gt;
3行目のボタンは、全てにlayout_weightを指定していますが、ボタン9のみ、layout_weightに2を指定しています。重要度に比例して領域を確保するので、1:1:2の比率で配置されているのがわかります。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQoRqWOzAog-Fv3tw3Gvc4mPUaFFvZ_h1XcbjErhNeepxUo-J8xezvkAA5jLK_l8iUvvuemEZd3sDthtyP4AKaA5ybO86yX9UiUiMfczbtVVx85siCD8GjTeXAlLFeHsLt7rfOA93W9pI/s1600/device-2011-09-30-234040+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQoRqWOzAog-Fv3tw3Gvc4mPUaFFvZ_h1XcbjErhNeepxUo-J8xezvkAA5jLK_l8iUvvuemEZd3sDthtyP4AKaA5ybO86yX9UiUiMfczbtVVx85siCD8GjTeXAlLFeHsLt7rfOA93W9pI/s400/device-2011-09-30-234040+2.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;

コードレビュー&lt;/h4&gt;
では、レイアウトのソースコードを見てみましょう。
Sample01プロジェクトの/res/layout/chapter03.xmlを開いてください。

&lt;br /&gt;
&lt;pre class=&quot;brush: xml; highlight: [21,23,27,29,33,35,57,59,70,72,76,78,82,84]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&amp;gt;
    &amp;lt;!-- 
        横方向均等配置をするため、親要素のLinearLayoutのorientationをhorizontalに設定します。
        ここでは、layout_weightが肝です。指定された方向に対してウェイトが重い分だけ、拡がります。 
        デフォルトは0なので、1つの要素でも1を与えるとそれが残りの領域を占拠します。
        また、均等配置する方向が横の場合、layout_widthに有効な値をいれても無駄になるので0dpを入れます。
     --&amp;gt;
    &amp;lt;!-- 均等配置
         全ての要素にlayout_weight=&quot;1&quot;を設定 --&amp;gt;
    &amp;lt;LinearLayout
        android:orientation=&quot;horizontal&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button1&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter03_button1&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button2&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter03_button2&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button3&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter03_button3&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;!-- 1つの要素だけlayout_weightを設定
         ただし、layout_weightが設定されてないボタンが表示されるように、
         layout_width=&quot;wrap_content&quot;にしてます。 --&amp;gt;
    &amp;lt;LinearLayout
        android:orientation=&quot;horizontal&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button4&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/chapter03_button4&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button5&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/chapter03_button5&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button6&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter03_button6&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;!-- 全ての要素にlayout_weightを設定
         但し、button9のみweightを2にしている --&amp;gt;
    &amp;lt;LinearLayout
        android:orientation=&quot;horizontal&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button7&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter03_button7&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button8&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_weight=&quot;1&quot;
            android:text=&quot;@string/chapter03_button8&quot; /&amp;gt;
        &amp;lt;Button
            android:id=&quot;@+id/button9&quot;
            android:layout_width=&quot;0dp&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_weight=&quot;2&quot;
            android:text=&quot;@string/chapter03_button9&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;b&gt;注目するべきは、layout_widthの値を0dpにしているところです&lt;/b&gt;&lt;/span&gt;。dpという単位は初めて聞いたと思いますが、これはAndroidで各端末の解像度の違いを吸収するための単位です。基本的にdpを使ってレイアウトをするのですが、単位は他の記事で扱おうと思っているので、ここではこの辺で割愛します。&lt;br /&gt;
&lt;br /&gt;
じゃあなんで注目やねんという話ですが、&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;layout_widthに0dp以外の有効な値を入れると、無駄に解析が入ってしまって非効率だからです&lt;/span&gt;&lt;/b&gt;。モバイル端末は基本的に非力だしバッテリー持たせる必要があるので、無駄な処理は極力削ります。それはプログラムだけでなく、レイアウトのXMLでも言えるのです。&lt;br /&gt;
&lt;br /&gt;
layout_weightの効能は、LinearLayoutのorientationの方向で意味づけが決まるので、horizontalの場合は、横方向に効きます。なので、layout_width=&quot;0dp&quot;なわけです。&lt;br /&gt;
&lt;br /&gt;
均等配置がlayout_weightを指定するだけで簡単にできることがわかってもらえたかと思います。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/8398014526129312264/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter03.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/8398014526129312264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/8398014526129312264'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/10/chapter03.html' title='Chapter03: 横方向に均等配置'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKQBc-Q546bqPgmDUVkIE5n0oT6ic3xH9bmP2drmpnprpHvk7B3ZVO4TjPztsJfwA4RFDPm6ABYOJWbYadoo_mnF-PiUeGq2zyrWA-SmhiQnDmhXKgx6Gso5DkbQ6gvn5shBQ_v5UqikU/s72-c/device-2011-09-30-234040.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-5806125961921404030</id><published>2011-09-30T18:14:00.000+09:00</published><updated>2011-09-30T18:36:58.800+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="RelativeLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML概要"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Chapter02: RelativeLayoutの特徴</title><content type='html'>次はRelativeLayoutの説明をします。&lt;br /&gt;
RelativeLayoutとは、相対レイアウト用のレイアウトです。子要素を親要素であるRelativeLayoutから相対的に配置することができます。また、子要素同士も、id指定で配置することができます。&lt;br /&gt;
&lt;br /&gt;
では、サンプルを見てみましょう。&lt;br /&gt;
サンプルアプリで、メニューを押して、chapter02を選択してください。以下のような画面になります。&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjTe0wHfRC-J8Cc8cTHZF1uGJDW7pvyYKXtK968UFGH70NugEAfqcuyxHWMK9tBkhAdmrZENhyphenhyphenVMXq1appTKa_qHvk92mZcSoc-DFMbwOQGWkYbtN79tqTxxA_TC81lytX44yP8nKLj6w/s1600/device-2011-09-30-165700.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjTe0wHfRC-J8Cc8cTHZF1uGJDW7pvyYKXtK968UFGH70NugEAfqcuyxHWMK9tBkhAdmrZENhyphenhyphenVMXq1appTKa_qHvk92mZcSoc-DFMbwOQGWkYbtN79tqTxxA_TC81lytX44yP8nKLj6w/s320/device-2011-09-30-165700.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
この画面は、RelativeLayoutの下に、各ポジションを表すTextViewを配置しています。LinearLayoutと違って、自由度が大きいことがわかるかと思います。&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
赤枠で囲まれているのが、親要素のRelativeLayoutに対して相対的な配置です。&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
青枠で囲まれているのが、子要素の「中央」というTextViewに対して相対的な配置です。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibREzIpruDGq9NRLafXgWUkucbnamXRgXTuRHxSNPqfTbfYpV39Nhj08AMELrNtg79dpp1Z67CP67436xzNMnzIHk9JvVg7RwIPXFTdC3oWJr9dNTkIHMC9uJj4fQ3QVkRiEwgePL8Cvw/s1600/device-2011-09-30-165700+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibREzIpruDGq9NRLafXgWUkucbnamXRgXTuRHxSNPqfTbfYpV39Nhj08AMELrNtg79dpp1Z67CP67436xzNMnzIHk9JvVg7RwIPXFTdC3oWJr9dNTkIHMC9uJj4fQ3QVkRiEwgePL8Cvw/s320/device-2011-09-30-165700+2.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;
コードレビュー&lt;/h4&gt;
では、レイアウトのソースコードを見てみましょう。&lt;br /&gt;
Sample01プロジェクトの/res/layout/chapter02.xmlを開いてください。&lt;br /&gt;
&lt;br /&gt;
注目するべきところは、子要素であるTextViewの以下の属性です。
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;親要素に対する配置(指定値 = true, false)
    &lt;ul&gt;
&lt;li&gt;layout_alignParentTop・・・親要素の上部に要素を配置する&lt;/li&gt;
&lt;li&gt;layout_alignParentBogttom・・・親要素の下部に要素を配置する&lt;/li&gt;
&lt;li&gt;layout_alignParentLeft・・・親要素の左部に要素を配置する&lt;/li&gt;
&lt;li&gt;layout_alignParentRight・・・親要素の右部に要素を配置する&lt;/li&gt;
&lt;li&gt;layout_centerInParent・・・親要素の縦横の中央に要素を配置する&lt;/li&gt;
&lt;li&gt;layout_centerVertical・・・親要素の縦方向の中央に要素を配置する&lt;/li&gt;
&lt;li&gt;layout_centerHorizontal・・・親要素の横方向の中央に要素を配置する&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;子要素同士に対する配置(指定値 = 要素のid)&lt;br /&gt;
    &lt;ul&gt;
&lt;li&gt;layout_above・・・指定された要素の上に配置する&lt;/li&gt;
&lt;li&gt;layout_below・・・指定された要素の下に配置する&lt;/li&gt;
&lt;li&gt;layout_toLeftOf・・・指定された要素の左に配置する&lt;/li&gt;
&lt;li&gt;layout_toRightOf・・・指定された要素の右に配置する&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
子要素同士で指定しているidは、中央に配置した要素@id/CenterInParentに対してです。

属性名にalignとかcenterとか出てくるので、Webデザイナーの人でも直観的にわかりやすいかなと思います。

&lt;br /&gt;
&lt;pre class=&quot;brush: xml; highlight: [19,20,27,28,35,36,43,44,51,68,69,79,80,90,91,101,102]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;RelativeLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&amp;gt;
    &amp;lt;!-- 
        RelativeLayoutは相対レイアウトです。
        RelativeLayoutの下のウィジェット類は、親のRelativeLayoutに対して相対的に配置されます。
        ■がそれです。
        ■   ■
        
          ■
          
        ■   ■
      --&amp;gt;
    &amp;lt;!-- 親要素に対して左上に配置 --&amp;gt;
    &amp;lt;TextView
        android:id=&quot;@+id/LeftTop&quot;
        android:layout_alignParentLeft=&quot;true&quot;
        android:layout_alignParentTop=&quot;true&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter02_left_top&quot; /&amp;gt;
    &amp;lt;!-- 親要素に対して左下に配置 --&amp;gt;
    &amp;lt;TextView
        android:id=&quot;@+id/LeftBottom&quot;
        android:layout_alignParentLeft=&quot;true&quot;
        android:layout_alignParentBottom=&quot;true&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter02_left_bottom&quot; /&amp;gt;
    &amp;lt;!-- 親要素に対して右上に配置 --&amp;gt;
    &amp;lt;TextView
        android:id=&quot;@+id/RightTop&quot;
        android:layout_alignParentRight=&quot;true&quot;
        android:layout_alignParentTop=&quot;true&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter02_right_top&quot; /&amp;gt;
    &amp;lt;!-- 親要素に対して右下に配置 --&amp;gt;
    &amp;lt;TextView
        android:id=&quot;@+id/RightBottom&quot;
        android:layout_alignParentRight=&quot;true&quot;
        android:layout_alignParentBottom=&quot;true&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter02_right_bottom&quot; /&amp;gt;
    &amp;lt;!-- 親要素に対して中央に配置 --&amp;gt;
    &amp;lt;TextView
        android:id=&quot;@+id/CenterInParent&quot;
        android:layout_centerInParent=&quot;true&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter02_center_in_parent&quot; /&amp;gt;
    &amp;lt;!-- ここから、中央の要素に対して相対配置します。□がそれです。
         ■   ■
           □
          □■□
           □
         ■   ■
     --&amp;gt;
    &amp;lt;!-- 上
        layout_aboveで指定されたIDの要素の上に配置されます。
        横方向で中央揃えするために、layout_centerHorizontalをtrueにしてます。
     --&amp;gt;
    &amp;lt;TextView
        android:id=&quot;@+id/above&quot;
        android:layout_above=&quot;@id/CenterInParent&quot;
        android:layout_centerHorizontal=&quot;true&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter02_above&quot; /&amp;gt;
    &amp;lt;!-- 下
        layout_belowで指定されたIDの要素の下に配置されます。
        横方向で中央揃えするために、layout_centerHorizontalをtrueにしてます。
     --&amp;gt;
    &amp;lt;TextView
        android:id=&quot;@+id/below&quot;
        android:layout_below=&quot;@id/CenterInParent&quot;
        android:layout_centerHorizontal=&quot;true&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter02_below&quot; /&amp;gt;
    &amp;lt;!-- 左
        layout_toLeftOfで指定されたIDの要素の左に配置されます。
        縦方向で中央揃えするために、layout_centerVerticalをtrueにしてます。
    --&amp;gt;
    &amp;lt;TextView
        android:id=&quot;@+id/toLeftOf&quot;
        android:layout_toLeftOf=&quot;@id/CenterInParent&quot;
        android:layout_centerVertical=&quot;true&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter02_to_left_of&quot; /&amp;gt;
    &amp;lt;!-- 右
        layout_toRightOfで指定されたIDの要素の右に配置されます。
        縦方向で中央揃えするために、layout_centerVerticalをtrueにしてます。
    --&amp;gt;
    &amp;lt;TextView
        android:id=&quot;@+id/toRightOf&quot;
        android:layout_toRightOf=&quot;@id/CenterInParent&quot;
        android:layout_centerVertical=&quot;true&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter02_to_right_of&quot; /&amp;gt;
&amp;lt;/RelativeLayout&amp;gt;
&lt;/pre&gt;
RelativeLayoutが便利なところは、中央に要素を置くのが簡単なところです。画像を中央に配置するなど、layout_centerInParentを指定するだけでよいので、画像を使った表示の場合などによく使ってます。&lt;br /&gt;
LinearLayoutに比べると、思った通りに要素の配置が行いやすいはずです。そのかわり、XMLでの要素指定が複雑化する場合があるので、把握するのが大変になったりします。&lt;br /&gt;
&lt;br /&gt;
全てをRelativeLayoutで配置するのではなく、LinearLayoutとRelativeLayoutを上手に使って配置するのがよいでしょう。
</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/5806125961921404030/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/09/chapter02-relativelayout.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/5806125961921404030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/5806125961921404030'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/09/chapter02-relativelayout.html' title='Chapter02: RelativeLayoutの特徴'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjTe0wHfRC-J8Cc8cTHZF1uGJDW7pvyYKXtK968UFGH70NugEAfqcuyxHWMK9tBkhAdmrZENhyphenhyphenVMXq1appTKa_qHvk92mZcSoc-DFMbwOQGWkYbtN79tqTxxA_TC81lytX44yP8nKLj6w/s72-c/device-2011-09-30-165700.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-3618185093120957225</id><published>2011-09-29T19:41:00.001+09:00</published><updated>2011-09-29T19:41:22.249+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="デバッグ"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Android端末で開発中のアプリを試すための設定</title><content type='html'>レイアウトの記事を書いている途中でまた気づいたので、また別の話題になりますが、Android端末で開発中のアプリを試すための設定方法です。&lt;br /&gt;
&lt;br /&gt;
まず、ホーム画面でメニューボタンを押し、設定を押します。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg02RzOcxw92g-OPAQtcXEXFuPHSgTgTnBk0eokGYAHnATcZbcXNJDFuStI1JupEML-BPM12wJu06ZMTniEhjcwYjk39VziVdJH6Y2Ggq8uun0hOL5T68MQ0PehkV9r05Z1Hl2dmw5_QgQ/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-29+19.22.38.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg02RzOcxw92g-OPAQtcXEXFuPHSgTgTnBk0eokGYAHnATcZbcXNJDFuStI1JupEML-BPM12wJu06ZMTniEhjcwYjk39VziVdJH6Y2Ggq8uun0hOL5T68MQ0PehkV9r05Z1Hl2dmw5_QgQ/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-29+19.22.38.png&quot; width=&quot;227&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;次に、設定のリスト内から、アプリケーションを選択します。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihRXpicVM0brSJqnR18qmFRofwGYjzpYEw6PnMqsamHrbauabqKeryetEst3XDbjglTEh3E7G-VW_jsXVd2lW7oeYTU7LTd0Yf54ngLxZFp5MGUrqV0p2Cunxn1Ma1Mct4Xn-xFbG8gM8/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-29+19.22.56.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihRXpicVM0brSJqnR18qmFRofwGYjzpYEw6PnMqsamHrbauabqKeryetEst3XDbjglTEh3E7G-VW_jsXVd2lW7oeYTU7LTd0Yf54ngLxZFp5MGUrqV0p2Cunxn1Ma1Mct4Xn-xFbG8gM8/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-29+19.22.56.png&quot; width=&quot;227&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;提供元不明のアプリのインストールを許可するにチェックを入れます。これは、普段はチェックを外しておいたほうが安全です。野良アプリ（Android Marketに登録されていないアプリ）とかインストールする場合はチェックが必要です。&lt;br /&gt;
&lt;br /&gt;
続いて、開発を選択します。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiptKlG4WtUSBmUAS3lfLZZ1opycp9Pm2mfbRwkcYR9ZolMHg6JFNVnCI7Us2MfUPWYgLPdoerZUNjg59IDrMC72GROq3t_tA0ciplAdItLwX_hdfrBYirFaxkuZUZuEkgwKesA_mzcHrc/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-29+19.23.07.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiptKlG4WtUSBmUAS3lfLZZ1opycp9Pm2mfbRwkcYR9ZolMHg6JFNVnCI7Us2MfUPWYgLPdoerZUNjg59IDrMC72GROq3t_tA0ciplAdItLwX_hdfrBYirFaxkuZUZuEkgwKesA_mzcHrc/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-29+19.23.07.png&quot; width=&quot;227&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
すべてにチェックを入れます。疑似ロケーションを許可は、GPSアプリとかを作る場合のみほしい機能なので、特に入れなくてもいいですが、とりあえず。疑似ロケーションとは、東京にいながらにして京都にいるかのごとくGPSデータをいじったりすることです。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEK30XR1WxuYMwTVXny_c-mSjU8SyKPC6YXdKBse9_QflssffwUs0t7T_WiJf3ME9umB05CIJN3C00pGbrtlsMiRpMAvlLfPuwFwPquDueWtQe5b81WRhd0lsCLDD0_pTSPu7MDpV-qxc/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-29+19.23.22.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEK30XR1WxuYMwTVXny_c-mSjU8SyKPC6YXdKBse9_QflssffwUs0t7T_WiJf3ME9umB05CIJN3C00pGbrtlsMiRpMAvlLfPuwFwPquDueWtQe5b81WRhd0lsCLDD0_pTSPu7MDpV-qxc/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-29+19.23.22.png&quot; width=&quot;228&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
これで、Eclipseから実機に開発中のアプリをインストールする準備ができました。&lt;br /&gt;
&lt;br /&gt;
なお、開発中以外は全部外しておくことをお勧めします。&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;b&gt;変なアプリをインストールされても私は知りません！&lt;/b&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/3618185093120957225/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/09/android_29.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/3618185093120957225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/3618185093120957225'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/09/android_29.html' title='Android端末で開発中のアプリを試すための設定'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg02RzOcxw92g-OPAQtcXEXFuPHSgTgTnBk0eokGYAHnATcZbcXNJDFuStI1JupEML-BPM12wJu06ZMTniEhjcwYjk39VziVdJH6Y2Ggq8uun0hOL5T68MQ0PehkV9r05Z1Hl2dmw5_QgQ/s72-c/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-29+19.22.38.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-8739772548175498828</id><published>2011-09-29T17:01:00.001+09:00</published><updated>2011-09-29T17:01:18.782+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LinearLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML概要"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Chapter01：LinearLayoutの特徴</title><content type='html'>では、ようやくレイアウトXMLの説明に入ります。&lt;br /&gt;
今回は、サンプルアプリのChapter01でLinearLayoutの説明をします。&lt;br /&gt;
&lt;br /&gt;
まだプロジェクトをインポートしていない場合は、&lt;a href=&quot;http://chariderpato.blogspot.com/2011/09/eclipsezip.html&quot;&gt;こちらの記事&lt;/a&gt;を先に読んでください。&lt;br /&gt;
&lt;br /&gt;
先に説明しておきますが、Androidのレイアウト要素には、以下の種類があります。&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;LinearLayout(リニアレイアウト)&lt;/li&gt;
&lt;li&gt;RelativeLayout(リレーティブレイアウト)&lt;/li&gt;
&lt;li&gt;FrameLayout(フレームレイアウト)&lt;/li&gt;
&lt;li&gt;TableLayout(テーブルレイアウト)&lt;/li&gt;
&lt;li&gt;AbsoluteLayout(現在は非推奨)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
5種類ありますが、ほとんどの場合、上の3種類のみを使います。特に、LinearLayoutとRelativeLayoutを多用するので、この講座（基本編）では、この2つに絞って説明します。&lt;br /&gt;
&lt;h4&gt;そもそもLayoutって何？&lt;/h4&gt;
&lt;div&gt;
Layoutは、HTML的に平たくいうと、divタグみたいなものです。入れ物です。TableLayoutはtableタグみたいなものですが。しかし、名前が違うのでそれぞれ特徴があります。しかしここでは言及しません。&lt;/div&gt;
&lt;h4&gt;LinearLayoutって何？&lt;/h4&gt;
LinearLayoutは、もっとも素直なレイアウトで、左上詰めで子要素を配置するレイアウトです。一番多用するレイアウトです。子要素を配置する方向（縦か横か）を決めることができます。&lt;br /&gt;
Chapter01の画面は以下のようになっています。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf7kNw1VyeBpkoVApduqbQorpfSjLjbbEqW7N3Hqta-hutXqScHdWPd03PXtb5ri4DATQKjS-ESIMlnfEkGzyOGbI-xCuLonbAMntIY2Oxx0i2UQmBOPy2lJPLUdkDkI0LP87_sHdfI_Q/s1600/device-2011-09-29-155127.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf7kNw1VyeBpkoVApduqbQorpfSjLjbbEqW7N3Hqta-hutXqScHdWPd03PXtb5ri4DATQKjS-ESIMlnfEkGzyOGbI-xCuLonbAMntIY2Oxx0i2UQmBOPy2lJPLUdkDkI0LP87_sHdfI_Q/s320/device-2011-09-29-155127.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
この画面はLinearLayoutというレイアウトとTextViewというウィジェットで構成されています。パッと見では、全部縦方向に配置されているようにみえるかもしれませんので、視覚的に表してみます。青い枠のLinearLayoutの中に、赤い枠のLinearLayoutが入っています。赤い枠のほうは、横方向にレイアウトを配置しています。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYR6wQe531yEKZ9tbJqWqcGoYeG7VBjDE84vg81svScUE39lPdh3EHNLvSabTG1wCW7vWVscl4xwrRFgh4iPe98OsJLNFgLZ-5lvU2Jy-0osNDLj1czwwF9ZzDnkyb0TDRp-QwU8cH0Ro/s1600/device-2011-09-29-155127+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYR6wQe531yEKZ9tbJqWqcGoYeG7VBjDE84vg81svScUE39lPdh3EHNLvSabTG1wCW7vWVscl4xwrRFgh4iPe98OsJLNFgLZ-5lvU2Jy-0osNDLj1czwwF9ZzDnkyb0TDRp-QwU8cH0Ro/s320/device-2011-09-29-155127+2.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;コードレビュー&lt;/h4&gt;
では、レイアウトのソースコードを見てみましょう。&lt;br /&gt;
Sample01プロジェクトの、/res/layout/chapter01.xml&amp;nbsp;を開いて下さい。&lt;br /&gt;
&lt;br /&gt;
注目するべきところは、LinearLayoutという要素の、android:orientationという属性です。それ以外は単にテキストを表示しているだけなので、まぁそんなものだと思っておいてください。&lt;br /&gt;
&lt;br /&gt;
ちなみに、layout_widthとlayout_heightは要素の横幅、縦幅を表します。fill_parentだと親要素分全部使います。つまり、width: 100%;です。wrap_contentは、必要な分だけ使うという指定です。数値でも指定可能ですが、ひとまずはこの2つを押さえましょう。また、match_parentというのもあります。2.2以降では、fill_parentではなく、match_parentを使いますが、Xperiaがある限りは、fill_parentを使わざるをえません…。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: xml; highlight: [4, 30]&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;LinearLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;&amp;gt;
    &amp;lt;!-- ここから垂直方向 --&amp;gt;
    &amp;lt;TextView
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter01_linearlayout_vertical&quot; /&amp;gt;
    &amp;lt;TextView
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter01_test_1&quot; /&amp;gt;
    &amp;lt;TextView
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter01_test_2&quot; /&amp;gt;
    &amp;lt;TextView
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter01_test_3&quot; /&amp;gt;
    &amp;lt;TextView
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter01_linearlayout_horizontal&quot; /&amp;gt;
    &amp;lt;!-- ここから水平方向 --&amp;gt;
    &amp;lt;LinearLayout
        android:orientation=&quot;horizontal&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;&amp;gt;
        &amp;lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/chapter01_test_4&quot; /&amp;gt;
        &amp;lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/chapter01_test_5&quot; /&amp;gt;
        &amp;lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/chapter01_test_6&quot; /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;
    &amp;lt;!-- ここまで水平方向 --&amp;gt;
    &amp;lt;!-- また垂直方向 --&amp;gt;
    &amp;lt;TextView
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter01_test_7&quot; /&amp;gt;
    &amp;lt;TextView
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter01_test_8&quot; /&amp;gt;
    &amp;lt;TextView
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/chapter01_test_9&quot; /&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/pre&gt;
orientation属性は、子要素の配置方向を決定します。&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;vertical・・・縦方向&lt;/li&gt;
&lt;li&gt;horizontal・・・横方向&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
途中に存在するLinearLayoutも、親要素のLinearLayoutの子要素なので、あくまで縦方向に配置される要素として置いてあります。しかし、その中身は横方向に配置されています。&lt;br /&gt;
&lt;br /&gt;
単純な例でLinearLayoutを紹介しましたが、複雑なレイアウトも、ほとんどはLinearLayoutを入れ子にしたレイアウトです。縦方向の途中の要素で横方向のレイアウトが必要になったら、LinearLayoutを追加して、orientationをhorizontalに設定して配置。それを抜けたらまた縦方向。もし横方向内で縦のレイアウトが使いたい場合は、さらにLinearLayoutを入れ子にして…という感じです。&lt;br /&gt;
&lt;br /&gt;
divタグの中にdivタグを入れて、さらにdivタグを入れて…というのに似ています。&lt;br /&gt;
&lt;br /&gt;
LinearLayoutの特徴が分かっていただけましたでしょうか？&lt;br /&gt;
次回は、RelativeLayoutの特徴を説明します。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/8739772548175498828/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/09/chapter01linearlayout.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/8739772548175498828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/8739772548175498828'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/09/chapter01linearlayout.html' title='Chapter01：LinearLayoutの特徴'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf7kNw1VyeBpkoVApduqbQorpfSjLjbbEqW7N3Hqta-hutXqScHdWPd03PXtb5ri4DATQKjS-ESIMlnfEkGzyOGbI-xCuLonbAMntIY2Oxx0i2UQmBOPy2lJPLUdkDkI0LP87_sHdfI_Q/s72-c/device-2011-09-29-155127.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-6383961087696378557</id><published>2011-09-28T17:26:00.000+09:00</published><updated>2011-10-04T23:31:14.943+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DDMS"/><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="スクリーンショット"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>スクリーンショットを撮る方法(DDMS)</title><content type='html'>ふと記事を書いている途中で思って、これこそが重要じゃないかと気づきました。スクリーンショットですね。せっかくデザインしても、実際に端末見せたり、PCでエミュレータ起動して、「こんな感じで」とかするのはあまりにも無謀です。できるけど面倒臭いし、プレゼンとかに載せられない。&lt;br /&gt;
&lt;br /&gt;
ということで、スクリーンショットを撮る方法を書きます。&lt;br /&gt;
&lt;br /&gt;
スクリーンショットを撮るのは簡単です。DDMSです。&lt;br /&gt;
DDMSって何ぞ？という人は、&lt;a href=&quot;http://chariderpato.blogspot.com/2011/09/eclipseddms.html&quot;&gt;この記事をまず読んでください&lt;/a&gt;。&lt;br /&gt;
&lt;br /&gt;
では、DDMSのパースペクティブを開きます。&lt;br /&gt;
左上のデバイスの部分にカメラみたいなマークがありますね。これを押します。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmn1aLi4BrGIN8RKZSjROQSqHfBCEQ7He0h3BgbLVfle62RrAEgpNAlGwlalt5EolJ3v3FzXfV1G2D9bWszXZ7zJlmWiF8v8d9EOu5qE5t5tqpjoczEJCNdWE_Bu8gSf35rxVRPgdLSpc/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+17.10.41.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;273&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmn1aLi4BrGIN8RKZSjROQSqHfBCEQ7He0h3BgbLVfle62RrAEgpNAlGwlalt5EolJ3v3FzXfV1G2D9bWszXZ7zJlmWiF8v8d9EOu5qE5t5tqpjoczEJCNdWE_Bu8gSf35rxVRPgdLSpc/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+17.10.41.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;押したら、スクリーンショットのウィンドウが出てきます。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtIlcVp0DKh454MwOSqLfwqdYNWkGKaAITgMbNDoPY3fWbtl8_wOU3afsYz8ctjT3pS-yj-yr-gCTZEtImHhJR6cFy4l0eemj1uJhubVUtsVH2qh9CTNxBUcKzGTC2fkHGtWPNDxj_eyg/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+17.12.16.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtIlcVp0DKh454MwOSqLfwqdYNWkGKaAITgMbNDoPY3fWbtl8_wOU3afsYz8ctjT3pS-yj-yr-gCTZEtImHhJR6cFy4l0eemj1uJhubVUtsVH2qh9CTNxBUcKzGTC2fkHGtWPNDxj_eyg/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+17.12.16.png&quot; width=&quot;183&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
上にメニューがあります。&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;リフレッシュ・・・スクリーンショットを現在の画面で撮りなおす&lt;/li&gt;
&lt;li&gt;Rotate・・・スクリーンショットを回転させる&lt;/li&gt;
&lt;li&gt;保管・・・保存する&lt;/li&gt;
&lt;li&gt;コピー・・・クリップボードにコピーする&lt;/li&gt;
&lt;li&gt;終了・・・ウィンドウを閉じる&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB4zB42qO2GzP8qvHxMzHlKrXk3SlMHrwPG2AHII7eaZDGclUYcHkszJg70IytWFUyNDIgCUr8NihAgb8-Vgw95swd80HrTsdpqXiOUr6x7ElVefl2nP5T07KjX0aC9smLth3Kb77QTCw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+17.12.54.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;145&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB4zB42qO2GzP8qvHxMzHlKrXk3SlMHrwPG2AHII7eaZDGclUYcHkszJg70IytWFUyNDIgCUr8NihAgb8-Vgw95swd80HrTsdpqXiOUr6x7ElVefl2nP5T07KjX0aC9smLth3Kb77QTCw/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+17.12.54.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
デザインが終わったら、これでスクリーンショットを撮って、スライドに載せたり、Android Marketにアップしたりしましょう。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/6383961087696378557/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/09/ddms.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/6383961087696378557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/6383961087696378557'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/09/ddms.html' title='スクリーンショットを撮る方法(DDMS)'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmn1aLi4BrGIN8RKZSjROQSqHfBCEQ7He0h3BgbLVfle62RrAEgpNAlGwlalt5EolJ3v3FzXfV1G2D9bWszXZ7zJlmWiF8v8d9EOu5qE5t5tqpjoczEJCNdWE_Bu8gSf35rxVRPgdLSpc/s72-c/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+17.10.41.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-8752870304309893649</id><published>2011-09-28T14:32:00.003+09:00</published><updated>2011-09-28T17:05:44.595+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML概要"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウト種類"/><title type='text'>サンプルアプリの使い方について</title><content type='html'>さて、ようやくレイアウトの話になっていきます。まだサンプルプロジェクトをEclipseに用意してない人は、サンプルプロジェクトをElipseにインポートしておいてください。以下のURLで説明しています。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://chariderpato.blogspot.com/2011/09/eclipsezip.html&quot;&gt;Eclipseでプロジェクトをインポートする(zipのまま)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
インポートできているものとして話を進めます。&lt;br /&gt;
&lt;br /&gt;
サンプルアプリは、特に処理の実装はしておらず、あくまでもレイアウトをXMLでやるだけにしています。しかしたくさんのプロジェクトを作って説明するのはインポートする手間も増えて大変なので、ある程度の量を1つのプロジェクトにまとめています（今後はプロジェクト増える予定ですが）。&lt;br /&gt;
&lt;br /&gt;
では起動してみましょう。プロジェクト上で右クリックして、実行 &amp;gt; Androidアプリケーションを選択します。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPS48wXIsLYQ0JjKeLvt31m39ryeSFCXHvVr2EFcBawgsogNsdKVEG1TXf6UFQUuV4nCgjVC_QKTY_wf7mkouz3so4WIDYI25oZgeR-VEeqwSL-8hcDG1ppY3gfEW6aJMqbFv76Fy6w40/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+14.25.04.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;372&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPS48wXIsLYQ0JjKeLvt31m39ryeSFCXHvVr2EFcBawgsogNsdKVEG1TXf6UFQUuV4nCgjVC_QKTY_wf7mkouz3so4WIDYI25oZgeR-VEeqwSL-8hcDG1ppY3gfEW6aJMqbFv76Fy6w40/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+14.25.04.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;今回はエミュレータを起動させました。メニューを押してみましょう。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizWnc8IZuuHpM_Rm1YZXZNIN3aD4fo_3mgYRIg8mOEWCJ4cjN8_4GPfhBNOwV1PwoY2743cxvT8Hx9dSSMC8py2HQ5i4cFMtj8V56GIQd659cYaKiMhp5I6aEzeC-1KjQxXyQ0igJOxNU/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+14.25.32.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;392&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizWnc8IZuuHpM_Rm1YZXZNIN3aD4fo_3mgYRIg8mOEWCJ4cjN8_4GPfhBNOwV1PwoY2743cxvT8Hx9dSSMC8py2HQ5i4cFMtj8V56GIQd659cYaKiMhp5I6aEzeC-1KjQxXyQ0igJOxNU/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+14.25.32.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
chapter01～chapter06まで、レイアウトのサンプルが入っているので、このブログでそれぞれ説明していきます。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkS-YEtRkfLIjwMJ7k2vlJfGekvvlr8zwZpR6g2pYmDB6sXkeL2wZruG-v2LpcqEYg9bLHdajTehzdLVsFX06ZkujbFWdrOexjE6T_EMzZEnkQDl3RECzVO7BgIUO3xAIdiF3p4YyL0aY/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+14.25.40.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;392&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkS-YEtRkfLIjwMJ7k2vlJfGekvvlr8zwZpR6g2pYmDB6sXkeL2wZruG-v2LpcqEYg9bLHdajTehzdLVsFX06ZkujbFWdrOexjE6T_EMzZEnkQDl3RECzVO7BgIUO3xAIdiF3p4YyL0aY/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+14.25.40.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
次回は、chapter01について説明します。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/8752870304309893649/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/09/sample.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/8752870304309893649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/8752870304309893649'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/09/sample.html' title='サンプルアプリの使い方について'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPS48wXIsLYQ0JjKeLvt31m39ryeSFCXHvVr2EFcBawgsogNsdKVEG1TXf6UFQUuV4nCgjVC_QKTY_wf7mkouz3so4WIDYI25oZgeR-VEeqwSL-8hcDG1ppY3gfEW6aJMqbFv76Fy6w40/s72-c/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-28+14.25.04.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-6130382014124870440</id><published>2011-09-28T00:44:00.002+09:00</published><updated>2011-09-28T00:46:05.378+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="インポート"/><category scheme="http://www.blogger.com/atom/ns#" term="レイアウトXML講座"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Eclipseでプロジェクトをインポートする(zipのまま)</title><content type='html'>AndroidのレイアウトのXMLの講義を行うに当たって、サンプルプロジェクトを作成しています。それを元に、記事を書いていきたいなぁと思っているのですが、今回はそのサンプルプロジェクトをEclipseのワークスペースにインポートする方法をご紹介します。&lt;br /&gt;
&lt;br /&gt;
サンプルは、githubにアップしています。&lt;br /&gt;
&lt;a href=&quot;https://github.com/patorash/AndroidLayoutXmlStudy-Sample01&quot;&gt;https://github.com/patorash/AndroidLayoutXmlStudy-Sample01&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
gitを使ってプロジェクトを読み込むこともできますが、今回はzip形式で読み込む方法です。まず、ダウンロードボタンを押します。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLH1TWqzZ4D_miAOO5tnPLiYp_y8QO597wVjrClshkbDYVa_94329Ze446E9Dhu1fPG17HXfxL68qTDgp8tI-AQriVa3T8oKq9lATfSefFO69OgbhwqGtoxOurXntJq5794gGodgbwutM/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.06.48.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;275&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLH1TWqzZ4D_miAOO5tnPLiYp_y8QO597wVjrClshkbDYVa_94329Ze446E9Dhu1fPG17HXfxL68qTDgp8tI-AQriVa3T8oKq9lATfSefFO69OgbhwqGtoxOurXntJq5794gGodgbwutM/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.06.48.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
すると、ポップアップが出てくるので、Download .zip のほうを選択します。すると、zipでダウンロードされます。&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;インポートはzipのままでもできますから、解凍しないでください。&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzGsEGZNE71gCYMZywr_3orh88sycq1SBJ2q2sSw4v8NPxS-3Uy9RS-Q2q5fNiILw6Gp_jve3fmDPx8QvYFCzMReAp30fEySLl9kna4TaVQ2HEkdmBXAqkjgoLkOv5L_tfeIQSdthBTks/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.07.00.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;186&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzGsEGZNE71gCYMZywr_3orh88sycq1SBJ2q2sSw4v8NPxS-3Uy9RS-Q2q5fNiILw6Gp_jve3fmDPx8QvYFCzMReAp30fEySLl9kna4TaVQ2HEkdmBXAqkjgoLkOv5L_tfeIQSdthBTks/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.07.00.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
ダウンロードしたプロジェクトを、Eclipseにインポートします。ファイルより、インポートを選択します。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO7XlbVAx_mtmkluiPnch6J42tfLpO1hcZUDlOOd-Qn9usslzbF_Ov4hkcirapDPMr_8qEW-abStsW7s6gdhRjqTI6AnpWih1oN7spDOu1_knrWvF9z7YFPCLBsntJNsCJO5u9gXAYivo/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.15.29.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO7XlbVAx_mtmkluiPnch6J42tfLpO1hcZUDlOOd-Qn9usslzbF_Ov4hkcirapDPMr_8qEW-abStsW7s6gdhRjqTI6AnpWih1oN7spDOu1_knrWvF9z7YFPCLBsntJNsCJO5u9gXAYivo/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.15.29.png&quot; width=&quot;267&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
既存プロジェクトをワークスペースへを選択し、次へを押します。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB2bysbCkwVL3NFeh2n-fs6WgaQ5HqNL9daVLY5TKIyf2_EpWw99k5QbGlSq3-OeOfF4p8s5aNG9HD7HJtJV4n6WN6gzdtE2cq6A05kBBZALkrYs-qFqI-teP1-44BZqkL3U8AFBZiyBM/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.15.58.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB2bysbCkwVL3NFeh2n-fs6WgaQ5HqNL9daVLY5TKIyf2_EpWw99k5QbGlSq3-OeOfF4p8s5aNG9HD7HJtJV4n6WN6gzdtE2cq6A05kBBZALkrYs-qFqI-teP1-44BZqkL3U8AFBZiyBM/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.15.58.png&quot; width=&quot;310&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;さきほどダウンロードしたzipファイルを指定します。アーカイブ・ファイルの選択を選び、参照を押して、zipを選びます。すると、解析されて、プロジェクトが出てきます。出てきたのを確認したら、完了ボタンを押しましょう。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixF5wlNeDXrqwNj9v5lBPBcmuxxyi7asgpGXI2CUKPIYIJFF2_ij3NbUt0DipVDELBcPOK8I4pjOmg28prl5w-JKrD7lfsvi4PRxrzWOw4vYROjLzsw8INxVlWPyf-eVGhbRtIu3T09xg/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.16.41.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixF5wlNeDXrqwNj9v5lBPBcmuxxyi7asgpGXI2CUKPIYIJFF2_ij3NbUt0DipVDELBcPOK8I4pjOmg28prl5w-JKrD7lfsvi4PRxrzWOw4vYROjLzsw8INxVlWPyf-eVGhbRtIu3T09xg/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.16.41.png&quot; width=&quot;287&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;なんかビックリマークがでてます。これは、プロジェクトの状態がおかしいぞ！というマークです（自分もよくわかってないですが）。直しましょう。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhslaTWCS15F8uzwzdKYBMdPMJXfW9xKXiJZYMuIku9-QT4LhjN6genInl1XEHmb9ZN2YJZcuhxUtITVJirebMyWQPNRaxkX0Z_w_uOwOcFrKXyTJn3SqwLwPgTslAl9QkuoxuedD4TltQ/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.17.23.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhslaTWCS15F8uzwzdKYBMdPMJXfW9xKXiJZYMuIku9-QT4LhjN6genInl1XEHmb9ZN2YJZcuhxUtITVJirebMyWQPNRaxkX0Z_w_uOwOcFrKXyTJn3SqwLwPgTslAl9QkuoxuedD4TltQ/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.17.23.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;プロジェクトより、クリーンを選択します。プロジェクトを一度綺麗にしてビルドしなおすという作業をしてくれます。プロジェクト単位で指定もできますし、全プロジェクトをすることもできます。お好きなほうを選びましょう。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgczE5hW5ub6PCK8aUb7OtvF491Hzo177sxulAO8Da_1W47SIiEnt91aFT9PTp8gCRH_1wcSQuet0iaxGu2tYqQG5TzqwRTPTuBLk7fQwB3ybSGeCCx6fTfK1jA1eTVwX_uPX2uwuRcqqQ/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.17.40.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;242&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgczE5hW5ub6PCK8aUb7OtvF491Hzo177sxulAO8Da_1W47SIiEnt91aFT9PTp8gCRH_1wcSQuet0iaxGu2tYqQG5TzqwRTPTuBLk7fQwB3ybSGeCCx6fTfK1jA1eTVwX_uPX2uwuRcqqQ/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.17.40.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;クリーンが終わると、ビックリマークが消えました。これでOKです。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWPZrmgS1QD-O0VSzcHG6dCw0ZXyfkfQmL-Ij56T7RLenPJsn9z4yogh8EyfcqIU7HGmakAwlJ_svq6EDcfg3jx5WV66EhhzT3u06JPinX2bSQ3UlEONvnzIO7GraxVHRQRHLSfmEnIEI/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.17.50.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWPZrmgS1QD-O0VSzcHG6dCw0ZXyfkfQmL-Ij56T7RLenPJsn9z4yogh8EyfcqIU7HGmakAwlJ_svq6EDcfg3jx5WV66EhhzT3u06JPinX2bSQ3UlEONvnzIO7GraxVHRQRHLSfmEnIEI/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.17.50.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: -webkit-auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
以上で、サンプルプロジェクトのインポートが終わりました。&lt;br /&gt;
ようやく次回より、レイアウトXMLの説明ができそうです。</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/6130382014124870440/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/09/eclipsezip.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/6130382014124870440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/6130382014124870440'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/09/eclipsezip.html' title='Eclipseでプロジェクトをインポートする(zipのまま)'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLH1TWqzZ4D_miAOO5tnPLiYp_y8QO597wVjrClshkbDYVa_94329Ze446E9Dhu1fPG17HXfxL68qTDgp8tI-AQriVa3T8oKq9lATfSefFO69OgbhwqGtoxOurXntJq5794gGodgbwutM/s72-c/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+23.06.48.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-4757336454023764888</id><published>2011-09-27T22:27:00.002+09:00</published><updated>2011-10-04T23:31:32.373+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DDMS"/><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="デバッグ"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><title type='text'>Eclipseでデバッグするための方法の基礎（DDMS）</title><content type='html'>さて、WebデザイナーのためのレイアウトXML講座と言っているのに、未だにレイアウトXMLの話に入らなくてごめんなさい。もう心折れかけているかもしれませんが、もうしばらく辛抱してください。これを説明してからじゃないと、完全に心が折られると思ったのです。すみません。&lt;br /&gt;
&lt;br /&gt;
Androidを使っている人だったら見たことがあるかもしれませんが、アプリはエラーで強制終了することがあります。こんな画面です。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb-ToNJIBzQSBUmPPyFdazOw7IORvkIsBLbYjs_s4o2eXtrUQopjg2SRv9mG-RQtX9WrKSwyFfjxUBr7GFNV5TD1lFxc4Ott_qazLNgSzkMPYGDOcB5iAQWk5WZbajqfw4v1VdplSgNLE/s1600/device-2011-09-27-175509.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb-ToNJIBzQSBUmPPyFdazOw7IORvkIsBLbYjs_s4o2eXtrUQopjg2SRv9mG-RQtX9WrKSwyFfjxUBr7GFNV5TD1lFxc4Ott_qazLNgSzkMPYGDOcB5iAQWk5WZbajqfw4v1VdplSgNLE/s400/device-2011-09-27-175509.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
レイアウトを書いて、いざ確認しようと思ったら、いつか遭遇してしまう画面です。悲しいですね。一体なにがいけないの？プログラムがわからないとやっぱりダメなの？と、困惑することでしょう。画面を見ていても、エラーの原因はわかりません。デバッグ画面を見なければ。&lt;br /&gt;
&lt;br /&gt;
ということで、Eclipseのデバッグ画面を見る方法です。&lt;br /&gt;
Androidの場合、Javaのデバッグ画面とは別にDDMSというものがあります。DDMSとはDalvik Debug Monitor Serviceの略です。AndroidはJavaのVMではなく、Dalvik VMというものの上で動いているので、それをデバッグ用にモニタするものです。&lt;br /&gt;
&lt;br /&gt;
では、早速表示させてみましょう。
Eclipseの右上のほうには、パースペクティブというものがあります。今、Eclipseで扱っている機能を表してる感じです。Androidのコーディングをする場合はJavaのパースペクティブを表示しています。赤枠のところを押して、新しくパースペクティブを開きましょう。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaxYfp2hpunhLGn9jMtmavJCBprg8DXB_atB_Kd6hX6K09KSGUaMRwursi6ROfkBlopFK4dNgX-OG3qdvwksn9-dm5KgJDa_Ayl1QaBBDbBCtnS-U5oEbEUg2wQYvo9cYJEGnxuLoB5nI/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+17.44.18.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;186&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaxYfp2hpunhLGn9jMtmavJCBprg8DXB_atB_Kd6hX6K09KSGUaMRwursi6ROfkBlopFK4dNgX-OG3qdvwksn9-dm5KgJDa_Ayl1QaBBDbBCtnS-U5oEbEUg2wQYvo9cYJEGnxuLoB5nI/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+17.44.18.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
すると、候補が色々出てきます。DDMSを選択します。なかったら、その他を押して、そこからDDMSを選択します。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhFZJ_2VlIbeFYobzn8e9-ebhLzYPtxfWZ_PG0ELW117DtPrnqIx77c0IF6GzDFJquLdtHo2Rot1JzHasX9PJOlHE9EdXzEpePMgBvSwr8jUSSEVIw0kj2RvnYESHIIh42bCrJ2RMbGec/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+17.44.28.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;190&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhFZJ_2VlIbeFYobzn8e9-ebhLzYPtxfWZ_PG0ELW117DtPrnqIx77c0IF6GzDFJquLdtHo2Rot1JzHasX9PJOlHE9EdXzEpePMgBvSwr8jUSSEVIw0kj2RvnYESHIIh42bCrJ2RMbGec/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+17.44.28.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
すると、Javaのパースペクティブのボタンの横にDDMSというものができて、パースペクティブが切り替わり、DDMS用の画面が出てきます。以下のような感じです。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1-s5wk87CHuklceFpCA0koH47jglhyQ_C_P_1du3UQeHDQub1YvMV93tt76a5aX5UmEK8bz1AumnSXKJtnaYQ4fP0c8YjaLO4-gQFRZsbobforg5XgkXCv5u0ro2Nbq3X3jcw-f2r8NY/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+21.48.20.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;253&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1-s5wk87CHuklceFpCA0koH47jglhyQ_C_P_1du3UQeHDQub1YvMV93tt76a5aX5UmEK8bz1AumnSXKJtnaYQ4fP0c8YjaLO4-gQFRZsbobforg5XgkXCv5u0ro2Nbq3X3jcw-f2r8NY/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+21.48.20.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
エミュレータや端末をデバッグモードでつないでいたら、左上のほうに以下のような感じで表示されているはずです。表示される情報は1端末ごとなので、繋がっている端末を選択しましょう（エミュレータでもOK）。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj12Qm_48G3c0HVsTMDz37K3NDy5gcslets2-rxiO-E65eoWUlAUev_Oqqj5LhV8uGRAnsa0uB5G04umiu-xm-kyxNDmZG-kWXzWR5zmO-qVAvdXUSVUbZR3NSzcVDZX8ns3R7YIMl9r90/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+21.48.27.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj12Qm_48G3c0HVsTMDz37K3NDy5gcslets2-rxiO-E65eoWUlAUev_Oqqj5LhV8uGRAnsa0uB5G04umiu-xm-kyxNDmZG-kWXzWR5zmO-qVAvdXUSVUbZR3NSzcVDZX8ns3R7YIMl9r90/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+21.48.27.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
DDMSは多機能で私も全部使いこなしているわけではないですし、デザイナーの方にもDDMSの詳しい情報は今のところ必要ないと思うので、エラーの原因を調べるヒントを見る方法を説明します。それは、ログです。&lt;br /&gt;
&lt;br /&gt;
アプリが強制終了したら、DDMSにログが出力されます（設定次第では出力されませんが、普通は開発中は出力されます）。
Devicesでデバッグ用の端末を選択したあと、下のほうにあるLogCatを見ます。いろんなログが出ていると思いますが、エラーの原因を見る方法は簡単です。&lt;br /&gt;
&lt;br /&gt;
ログの表示レベルをEにします。右側にあるログレベルを表すアルファベットをクリックすると、そのログレベル以上のログしか表示されなくなります。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvAH438by_oRF5X5BJwmF2UY-mxcMK-Qsd_httfkcwBl5ToE9uxKED7x4w2O7tDsrB5gI9g3NHJ5s4z5AxbpUGYqz4AQQKGQPBJmt9jMxvWmKC_u9zrhhmVkSkrhDjCI7Q81nrkCjgenQ/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+17.55.58.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;82&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvAH438by_oRF5X5BJwmF2UY-mxcMK-Qsd_httfkcwBl5ToE9uxKED7x4w2O7tDsrB5gI9g3NHJ5s4z5AxbpUGYqz4AQQKGQPBJmt9jMxvWmKC_u9zrhhmVkSkrhDjCI7Q81nrkCjgenQ/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-27+17.55.58.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
エラーでアプリが落ちるときは、Eレベルのログになります。直近のエラーなので、一番下のログを見れば、だいたいわかるというわけです。見たことがあるログだったら、エラーの原因がわかりますし、わからない場合はそのエラーの原因でググれば、大体の情報はネット上にあります。&lt;br /&gt;
&lt;br /&gt;
今回は、AndroidManifest.xmlに指定されたActivityを定義し忘れていたので、ActivityNotFoundExceptionという例外が出ているというメッセージでした（もちろんわざとですよ！）。
このAndroidManifestにActivityの定義をし忘れるというのは、慣れてても時々やってしまうので、覚えておくといいと思います。本のサンプルを作っていると、定義をはしょられてて、DDMSを見て気づくことが結構あります。
</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/4757336454023764888/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/09/eclipseddms.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/4757336454023764888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/4757336454023764888'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/09/eclipseddms.html' title='Eclipseでデバッグするための方法の基礎（DDMS）'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb-ToNJIBzQSBUmPPyFdazOw7IORvkIsBLbYjs_s4o2eXtrUQopjg2SRv9mG-RQtX9WrKSwyFfjxUBr7GFNV5TD1lFxc4Ott_qazLNgSzkMPYGDOcB5iAQWk5WZbajqfw4v1VdplSgNLE/s72-c/device-2011-09-27-175509.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6569236911669928977.post-8411589808153701765</id><published>2011-09-26T17:49:00.002+09:00</published><updated>2011-10-04T23:30:26.155+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="基本編"/><category scheme="http://www.blogger.com/atom/ns#" term="開発環境構築"/><title type='text'>Eclipse Android用Javaフォーマッタのインポートを行う</title><content type='html'>&amp;nbsp;GoogleはAndroidのソースに関して、コーディングルールを設けています。&lt;br /&gt;
&amp;nbsp;Eclipseだと、ctrl + shift + F(Macだとcommand + shift + F)で、Javaのコードをフォーマットしてくれるのですが、デフォルトのままだとAndroid用のフォーマットではありません。
EclipseにAndroid用のフォーマットを記憶させるために、以下の作業をしましょう。&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;まず、以下のXMLをファイルとして保存します。
&lt;br /&gt;
（本来は、Androidのソースコードが公開されているhttp://android.git.kernel.orgに置いてあるのですが、2011/09/26現在、不正な攻撃を受けたためにアクセスできないようになっていますので、こちらでコピーを公開しています。その点をご容赦ください）&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;profiles version=&quot;10&quot;&amp;gt;
&amp;lt;profile name=&quot;Android&quot; version=&quot;10&quot;&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.align_type_members_on_columns&quot; value=&quot;false&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_assignment&quot; value=&quot;0&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_binary_expression&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_compact_if&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_conditional_expression&quot; value=&quot;80&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_enum_constants&quot; value=&quot;0&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_multiple_fields&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration&quot; value=&quot;16&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.blank_lines_after_imports&quot; value=&quot;1&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.blank_lines_after_package&quot; value=&quot;1&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.blank_lines_before_field&quot; value=&quot;1&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration&quot; value=&quot;0&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.blank_lines_before_imports&quot; value=&quot;1&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.blank_lines_before_member_type&quot; value=&quot;1&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.blank_lines_before_method&quot; value=&quot;1&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk&quot; value=&quot;1&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.blank_lines_before_package&quot; value=&quot;1&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations&quot; value=&quot;1&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_array_initializer&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_block&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_block_in_case&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_enum_constant&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_method_declaration&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_switch&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.brace_position_for_type_declaration&quot; value=&quot;end_of_line&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.comment.clear_blank_lines&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.comment.format_comments&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.comment.format_header&quot; value=&quot;false&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.comment.format_html&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.comment.format_source_code&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.comment.indent_parameter_description&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.comment.indent_root_tags&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.comment.line_length&quot; value=&quot;80&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.compact_else_if&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.continuation_indentation&quot; value=&quot;2&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer&quot; value=&quot;2&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line&quot; value=&quot;false&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indent_empty_lines&quot; value=&quot;false&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indent_statements_compare_to_block&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indent_statements_compare_to_body&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.indentation.size&quot; value=&quot;4&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_after_annotation&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_binary_operator&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_ellipsis&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_after_unary_operator&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_binary_operator&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_ellipsis&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional&quot; value=&quot;insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_semicolon&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_before_unary_operator&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation&quot; value=&quot;do not insert&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line&quot; value=&quot;false&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line&quot; value=&quot;false&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line&quot; value=&quot;false&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line&quot; value=&quot;false&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.lineSplit&quot; value=&quot;100&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body&quot; value=&quot;0&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve&quot; value=&quot;1&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.tabulation.char&quot; value=&quot;space&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.tabulation.size&quot; value=&quot;4&quot;/&amp;gt;
&amp;lt;setting id=&quot;org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations&quot; value=&quot;false&quot;/&amp;gt;
&amp;lt;/profile&amp;gt;
&amp;lt;/profiles&amp;gt;
&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
次に、保存したxmlファイルをEclipseに読み込ませます。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
設定画面を開いて（Winならばウィンドウ &amp;gt; 設定。Macならば、Eclipse &amp;gt; 環境設定）&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Java &amp;gt; コード・スタイル &amp;gt; フォーマッター を開き、インポートを選択し、上記のxmlのファイルを読み込ませます。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipP9o1Q4qSVL3N-SgJEvnuor_BckMstt4mOYg3uJOrBtoESh1xzrxVon3pIosE8mlw7lObTYEvYnHmmwZNqLBCRuTQPYYnMKtcemH-J6QlttnlLUD5UGzQl05m4cvpCseyuFLHiAYVVww/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-26+17.53.26.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipP9o1Q4qSVL3N-SgJEvnuor_BckMstt4mOYg3uJOrBtoESh1xzrxVon3pIosE8mlw7lObTYEvYnHmmwZNqLBCRuTQPYYnMKtcemH-J6QlttnlLUD5UGzQl05m4cvpCseyuFLHiAYVVww/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-26+17.53.26.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
そして、アクティブなプロファイルの箇所で、Androidを選択し、適用ボタンを押します。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiocV11THOAlqRcnbwrdsNAdFa2zl6JuJ2L0_dlrVZdmfJQgY8CsoHWhzM18eyhZCF_Y53TZz0UDBE3pfuhonNxV48c7JHR6LsVPcKCHS2aa1WKu8HJWb-5nTsNiCBityuEAa_TVnVYPFU/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-26+17.54.07.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;282&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiocV11THOAlqRcnbwrdsNAdFa2zl6JuJ2L0_dlrVZdmfJQgY8CsoHWhzM18eyhZCF_Y53TZz0UDBE3pfuhonNxV48c7JHR6LsVPcKCHS2aa1WKu8HJWb-5nTsNiCBityuEAa_TVnVYPFU/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-26+17.54.07.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
これで、Eclipseのソースフォーマット機能を使ったときに、Androidのコーディングルールでフォーマットしてくれます。（変数名などは別です。あくまでフォーマットだけです）&lt;br /&gt;
以上です。
</content><link rel='replies' type='application/atom+xml' href='http://chariderpato.blogspot.com/feeds/8411589808153701765/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://chariderpato.blogspot.com/2011/09/eclipse-androidjava.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/8411589808153701765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6569236911669928977/posts/default/8411589808153701765'/><link rel='alternate' type='text/html' href='http://chariderpato.blogspot.com/2011/09/eclipse-androidjava.html' title='Eclipse Android用Javaフォーマッタのインポートを行う'/><author><name>尾古 豊明(Oko Toyoaki)</name><uri>http://www.blogger.com/profile/18070874930379538889</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mgmZh0HnR993XztG8U_8TysCQrL7P-1j7UQhlIOpq2zJJ92au5gUysMv4UFDH-TbhXe68rUaom50B_WW7iveJ5alzl_PpFeTmVP0l1SP7xnKLjY9xuQjUNwYPsJd-g/s220/icon_default.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipP9o1Q4qSVL3N-SgJEvnuor_BckMstt4mOYg3uJOrBtoESh1xzrxVon3pIosE8mlw7lObTYEvYnHmmwZNqLBCRuTQPYYnMKtcemH-J6QlttnlLUD5UGzQl05m4cvpCseyuFLHiAYVVww/s72-c/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588+2011-09-26+17.53.26.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>