「LinearLayout」の編集履歴(バックアップ)一覧はこちら
LinearLayout - (2010/09/20 (月) 13:00:15) の最新版との変更点
追加された行は緑色になります。
削除された行は赤色になります。
**LinearLayoutサンプル
LinearLayoutクラスをXMLで定義して画面を作ってみました。
JAVAソースはタイトル変更と参照XMLの名称を変更しただけで
***XMLの内容
#html2(){{{{{{
<table bgcolor="white" width="500">
<tr>
<td><b>
?xml version="1.0" encoding="utf-8"?><br>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br>
android:id="@+id/base001"--------(1)<br>
android:orientation="vertical"<br>
android:background="#FFFFFF"<br>
android:layout_width="fill_parent"<br>
android:layout_height="fill_parent"<br>
><br>
<RadioGroup<br>
android:id="@+id/radiogroup"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"><br>
<RadioButton<br>
android:id="@+id/rdio001"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"<br>
android:textColor="#000000"<br>
android:text="STAR TREK The Original Series"<br>
/><br>
<RadioButton<br>
android:id="@+id/rdio002"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"<br>
android:textColor="#000000"<br>
android:text="STAR TREK The Next Generation"<br>
/><br>
<RadioButton<br>
android:id="@+id/rdio003"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"<br>
android:textColor="#000000"<br>
android:text="STAR TREK The Deep Space Nine"<br>
/><br>
<RadioButton<br>
android:id="@+id/rdio004"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"<br>
android:textColor="#000000"<br>
android:text="STAR TREK The Voyager"<br>
/><br>
<RadioButton<br>
android:id="@+id/rdio005"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"<br>
android:textColor="#000000"<br>
android:text="STAR TREK Enterprise"<br>
/><br>
</RadioGroup><br>
<LinearLayout<br>
android:id="@+id/base002"--------(2)<br>
android:orientation="horizontal"<br>
android:layout_width="310px"<br>
android:layout_height="wrap_content"<br>
android:layout_gravity="center_horizontal"<br>
android:background="#0B2BD7"<br>
><br>
<CheckBox<br>
android:id="@+id/checkbox001"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"<br>
android:text="TV版"<br>
/><br>
<CheckBox<br>
android:id="@+id/checkbox002"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"<br>
android:text="劇場版"<br>
/><br>
<CheckBox<br>
android:id="@+id/checkbox003"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"<br>
android:text="その他"<br>
/><br>
</LinearLayout><br>
<LinearLayout<br>
android:id="@+id/base003"--------(3)<br>
android:orientation="horizontal"<br>
android:layout_width="310px"<br>
android:layout_height="wrap_content"<br>
android:layout_gravity="center_horizontal"<br>
android:background="#FF0000"<br>
><br>
<Button<br>
android:id="@+id/button001"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"<br>
android:text="送信"<br>
/><br>
<Button<br>
android:id="@+id/button002"<br>
android:layout_width="wrap_content"<br>
android:layout_height="wrap_content"<br>
android:text="キャンセル"<br>
/><br>
</LinearLayout><br>
</LinearLayout><br><br> }}}}}}
AVDマネージャを起動して、&bold(){"Installed Packages"}を選択します。
#image(http://www35.atwiki.jp/andro_degu/pub/install/eclipse13.gif,width=400,title=プラグインの設定(13),http://www35.atwiki.jp/andro_degu/pub/install/eclipse13.gif,blank)
&bold(){Update All...ボタン}を押下します。
これでAndroidのパッケージだけがアップデートできます。
**LinearLayoutサンプル
LinearLayoutクラスをXMLで定義して画面を作ってみました。
JAVAソースはタイトル変更と参照XMLの名称を変更しただけで
***XMLの内容
#highlight(){
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/base001" --------------------------------------(1)
android:orientation="vertical"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/rdio001"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="STAR TREK The Original Series"
/>
<RadioButton
android:id="@+id/rdio002"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="STAR TREK The Next Generation"
/>
<RadioButton
android:id="@+id/rdio003"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="STAR TREK The Deep Space Nine"
/>
<RadioButton
android:id="@+id/rdio004"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="STAR TREK The Voyager"
/>
<RadioButton
android:id="@+id/rdio005"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="STAR TREK Enterprise"
/>
</RadioGroup>
<LinearLayout
android:id="@+id/base002"--------------------------------------(2)
android:orientation="horizontal"
android:layout_width="310px"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#0B2BD7"
>
<CheckBox
android:id="@+id/checkbox001"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TV版"
/>
<CheckBox
android:id="@+id/checkbox002"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="劇場版"
/>
<CheckBox
android:id="@+id/checkbox003"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="その他"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/base003"--------------------------------------(3)
android:orientation="horizontal"
android:layout_width="310px"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#FF0000"
>
<Button
android:id="@+id/button001"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="送信"
/>
<Button
android:id="@+id/button002"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="キャンセル"
/>
</LinearLayout>
</LinearLayout>
}
&bold(){(1) 一番下のLinearLayoutです。ラジオボタンが乗っています。}
&bold(){(2) これが真ん中のLinearLayoutです。チェックボックスが乗っています}
&bold(){(3) これが一番上のLinearLayoutです。ボタンが乗っています。}
画面はLinearLayoutを3層に分けてみました。
(階層別に解りやすい様に色を変えています)
-&bold(){第1階層}
ラジオボタンを配置しています。
ただし、"RadioGroup "クラスを使用して"RadioButton"をグループ化しています。
れをしておかないと"RadioButton"の選択を1つだけにすることができません。
"RadioGroup"クラスを使用しなければ全ての"RadioButton"がチェック可能になります。
-&bold(){第2階層}
チェックボックスを配置しています。
LinearLayoutとしては独立しています。
-&bold(){第3階層}
ボタンを配置しています。
LinearLayoutとしては独立しています。
イメージはこんな感じ。
#image(http://www35.atwiki.jp/andro_degu/pub/layout/LinearLayout01_01.gif,width=400,title=レイアウト(1),http://www35.atwiki.jp/andro_degu/pub/layout/LinearLayout01_01.gif,blank)
**実行結果
#image(http://www35.atwiki.jp/andro_degu/pub/layout/LinearLayout01.gif,width=200,title=レイアウト(2),http://www35.atwiki.jp/andro_degu/pub/layout/LinearLayout01.gif,blank)
表示オプション
横に並べて表示:
変化行の前後のみ表示: