AndroidのUI - INDEX
レイアウトマネージャ | |
---|---|
Layout種類 | 説明 |
LinearLayout | |
TableLayout |
・LinearLayoutを継承
・TableRowを追加する
・TableRowを追加しない場合、一行を占める
・android:collapseColumns 幅縮小可能
・android:shrinkColumns 幅拡張可能
・android:stretchColumns 隠蔽
|
FrameLayout |
・ViewGroupを継承
・android:foreground 前景画像
・android:foregroundGravity 前景画像の配置位置
|
RelativeLayout |
・ViewGroupを継承
・Aの位置はBによって決められている。
先にBの位置を決める必要がある
|
GridLayout |
・GroupViewを継承
・HTMLのTableのようなもので、ColumnとRowがある
・android:columnCount 列数
・android:rowCount 行数
内部コンポーネント属性
・・android:layout_column 何列目
・・android:layout_columnSpan 何列を占めるか
・・android:layout_row 何行目
・・android:layout_rowSpan 何行を占めるか
・・android:layout_gravity 配置方法
|
AbsoluteLayout |
・ViewGroupを継承
・すべてのコンポーネントに対して位置、大きさを決める必要がある
・layout_x X座標
・layout_y Y座標
・使用推奨ではない。(deprecatedされている)
|
TextViewとその派生 | |
---|---|
TextView種類 | 説明 |
TextView |
・View継承
・EditTextとButtonの親クラス ・Text編集はできない
|
EditView |
・TextView継承
・Text編集可能 ・inputType属性で入力コンポーネントを決める ・AutoCompleteTextView派生 ・・自動完成 ・・Adapterと組み合わせて使用する ・ExtractEditText ・・UIではない ・・全画面入力支持 |
Button | ・TextVIew継承 ・Drawableの利用して画像をボタンとして使える ・・android:backgroud="@drawable/れソース名" ※Buttonの内容が多いときには背景画像は自動伸縮されるが、効果がよくない。 そのときには9Patch(.9.png)を使うのだ。 |
RadioButton | ・CompoundButton継承(Button継承) ・単一選択のボタンである ・android:checked |
CheckBox | ・CompoundButton継承(Button継承) ・複数選択のボタンである ・android:checked |
ToggleButton | ・CompoundButton継承(Button継承) ・android:checked ・android:textOff クローズ時表示テキスト ・android:textOff オープン時表示テキスト |
Switch | ・CompoundButton継承(Button継承) |
TextClock(AnalogClock) | 【TextClock】 ・TextVIew継承 ・いつも時間を表示するTextView ・android:textが無効 ・android:format12Hour ・android:format24Hour ・android:timeZone 【AnalogClock】 ・View継承 ・秒は表示しない ・ViewのonDrawをoverride ・android:dial 時計背景画像 ・android:hand_hour 時間画像 ・android:hand_minute 分画像 |
Chronometer | ・TextView継承 ・計測機 ・setBase(long base), setFormat(String format), start(). stop() ・setonChronometerTickListener 計測機変更リスナー設定 |
ImageViewとその派生 | |
---|---|
TextView種類 | 説明 |
ImageView | |
ImageButton | ・ImageView継承 ・画像ボタン |
ZoomButton | ・ImageButton継承 ・デフォルトで+、-drawable提供 ・@android:drawable/btn_minus/android:drawable/btn_plus |
QuickContactBadge | ・ImageView継承 ・assignContactFromEmail 画像をEmailに連携 ・assignContactFromPhone 画像電話番号に連携 ・assignContactUri 画像をUriに連携 |
AdapterViewとその派生 | |
---|---|
AdapterView種類 | 説明 |
AdapterView | |
ListView | ・AbsListView継承 ・android:divider
・android:dividerHeight
・android:entries
・android:footerDividersEnabled
|
ArrayAdapter | ・配列、Listを項目としてカプセル化する ・機能が少ない |
SimpleAdapter | 機能が多い、Listを項目としてカプセル化する |
SimpleCursorAdapter | SimpleAdapterと似ているが、Cursorのデータをカプセル化する |
BaseAdapter | 最大限Adapterの制御が可能。 |
AutoCompleteTextView MultiAutoCompleteTextView |
自動完成TextView |
GirdView | ・AbsListView継承 ・GridViewのカラムが1ならListViewとなる ・Android:columnWidth ・Android:gravity ・Adnroid:numColumns |
ExpandableListView | 展開できるListView。 ExpandableListAdapter |
Spinner |
リスト選択ダイアログである
・AbsSpinner extends AdapterViewを継承
・AdapterViewを提供すればいい
|
AdapterViewFlipper | ・AdapterViewAnimator継承 ・Adapterが提供する複数Viewの中で一つを表示する ・showPrevious() showNext()でどれ表示か制御 ・startFlipping() で自動次表示を制御 |
StackView | ・AdapterViewAnimator継承 ・Adapterが提供する複数Viewを重ねて表示 ・showPrevious() showNext()でどれ表示か制御 |
ProgressBar | |
---|---|
Progress種類 | 説明 |
ProgressBar | |
SeekBar | ・ProgressBar継承 ・android:thumb Drawableを指定しスクロール画像指定 |
RatingBar | ・ProgressBar継承 ・android:isIndicator 変更可能か ・android:numStarts 星数 ・android:rating デフォルト ・android:stepSize 最小変更星数 |
ViewAnimatorとその派生 ・FrameLayout継承 - 複数のViewを重ねることができるってこと ・名前の通り、View切り替え時の動画効果がある ・android:animateFirstView - 最初Viewの動画使用か ・android:inAnimation - 表示時の動画 ・android:outAnimation - 隠す時の動画 | |
---|---|
ViewAnimator種類 | 説明 |
ViewSwitcher |
・ViewAnimator継承
・setFactoryメソッドでView設定
|
ImageSwitcher | ・ViewSwitcher継承 ・ImageVIewと似ているが、動画効果がある 使用方法は、 1. ImageSwitcherにViewFactory提供(ViewFactoryはImageViewのみ生成する) 2. setImageDrawable, setImageResource, setImageURIメソッドで切り替え |
TextSwitcher | ・ViewSwitcher継承 ・ImageSwitcherと似ているが、ViewFactoryが返すのはTextViewだ。 |
ViewFlipper | ・ViewAnimator継承 ・addViewメソッドでViewを複数View追加 |
Dialog | |
---|---|
Dialog種類 | 説明 |
AlertDialog |
使用手順:
1. AlertDialog.Bulderオブジェクト
2. setTitle() OR setCustomTitle()
3. setIcon()
4. Dialog内容
・・setMessage()
・・setItems()
・・setSingleChoiceItems()
・・setMultiChoiceItems()
・・setAdapter()
・・setView()
5. setPositiveButton(), setNegativeButton(), setNeutralButton()
|
PopupWindow |
位置指定でpopup表示 |
DatePickerDialog | ・AlertDialog継承 ・日付選択ダイアログ |
TimePickerDialog | ・AlertDialog継承 ・時刻選択ダイアログ |
ProgressDialog | ・AlertDialog継承 ・進捗表示ダイアログ |
Menu | |
---|---|
Menu種類 | 説明 |
Menu |
・OnCreateOptionsMenu(Menu menu) - 生成
・onOptionsItemSelected(MenuItem mi) - Callback
・・SubMenu ・・MenuItem ・・ContextMenu MenuItemから他のActitivy起動例 |
PopupMenu | componentの相対位置で表示されるメニュー |
ContexMenu | 1. registerForContextMenu - 登録 2. onCreateContextMenu - 生成 3. onContextItemSelected - callback |