android.widget.LinearLayout
リファレンス:http://developer.android.com/reference/android/widget/LinearLayout.html
SUMMARY
継承するXML属性 |
android.view.Viewの属性を継承します。 |
android.view.ViewGroupの属性を継承します。 |
XML属性 | ||
属性 | 対応メソッド | 概要 |
android:baselineAligned | setBaselineAligned(boolean) | ベースラインに合わせて配置するかどうかを指定します。 |
android:baselineAlignedChildIndex | setBaselineAlignedChildIndex(int) | ベースラインとなる属性を持ったWidgetのインデックスを指定します。 |
android:gravity | setGravity(int) | オブジェクトの配置方法を指定します。 |
android:orientation | setOrientation(int) | 配置する向きを指定します。 |
XML属性
- android:baselineAligned
指定値 デフォルト 動作 true ○ レイアウト内の各Widgetのベースラインに合わせて配置します。 false レイアウト内の各Widgetのベースラインに合わせて配置しません。 - サンプルコード
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/TestSample" android:layout_width="fill_parent" android:layout_height="fill_parent" android:baselineAligned="true" android:orientation="horizontal"> <TextView android:id="@+id/Text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="name"> </TextView> <EditText android:id="@+id/EText1" android:layout_height="wrap_content" android:layout_width="fill_parent"/> </LinearLayout>
- サンプルコード
- android:baselineAlignedChildIndex
追加した順番のインデックスで指定します。- サンプルコード
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:baselineAligned="true"> <TextView android:layout_height="40dip" android:layout_width="wrap_content" android:text="text"/> <EditText android:layout_height="50dip" android:layout_width="wrap_content"/> <Button android:layout_height="60dip" android:layout_width="wrap_content" android:text="Bu"/> <LinearLayout android:baselineAlignedChildIndex="2" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_height="30dip" android:layout_width="wrap_content" android:text="text2"/> <EditText android:layout_height="60dip" android:layout_width="wrap_content"/> <Button android:layout_height="90dip" android:layout_width="wrap_content" android:text="Bu2"/> </LinearLayout> </LinearLayout>
- サンプルコード
- android:gravity
"|"で区切って複数指定することが可能です。指定値 デフォルト 動作 top コンテナの上部に配置し、サイズ変更は行いません。 bottom コンテナの下部に配置し、サイズ変更は行いません。 left コンテナの左側に配置し、サイズ変更は行いません。 right コンテナの右側に配置し、サイズ変更は行いません。 center_vertical 上下中央に配置し、サイズ変更は行いません。 fill_vertical オブジェクトの高さを、コンテナのサイズに合わせます。 center_horizontal 左右中央に配置し、サイズ変更は行いません。 fill_horizontal オブジェクトの幅を、コンテナのサイズに合わせます。 center 上下左右中央に配置し、サイズ変更は行いません。 fill ○ オブジェクトの高さ・幅を、コンテナのサイズに合わせます。 clip_vertical top/bottomの追加オプションとして、オブジェクトの上部/下部の境界をコンテナの境界に合わせます。 clip_horizontal left/rightの追加オプションとして、オブジェクトの左側/右側の境界をコンテナの境界に合わせます。
- android:orientation
指定値 デフォルト 動作 horizontal ○ 水平方向に並べます。 vertical 垂直方向に並べます。
- android:orientationのデフォルト値はhorizontalです。Eclipse3.6にてorientation属性を抜いたところ、horizontalの動作をいたしました -- 2011-06-29 (水) 14:57:04