ViewGroup.LayoutParamsクラス

android.viewViewGroup.LayoutParamsクラス

ViewGroup.LayoutParams

 状態:-  閲覧数:1,455  投稿日:2014-03-13  更新日:2014-04-02  
ビューグループに関連付けられているレイアウト情報を取り扱う
・Android全レイアウトで共通利用できる「XML属性」及び「定数」を定義している

public static class ViewGroup.LayoutParams
・ViewGroupクラスの中に記述したクラス(=ネストしたクラス)
・staticが付与されているので、ネストクラスの中でも(あるいはネストクラスとは厳密には異なる)static なメンバクラス
・「トップレベル」のクラスやインターフェイス(ネストしていないクラスやインターフェイス)と同じ
・エンクロージング型のstaticメンバー


クラス構成

 閲覧数:370 投稿日:2014-03-13 更新日:2014-04-02 

親クラス



java.lang.Object
  ↳ android.view.ViewGroup.LayoutParams




子クラス


直接
AbsListView.LayoutParams, AbsoluteLayout.LayoutParams, Gallery.LayoutParams, ViewGroup.MarginLayoutParams, ViewPager.LayoutParams, WindowManager.LayoutParams

間接
ActionBar.LayoutParams, DrawerLayout.LayoutParams, FrameLayout.LayoutParams, GridLayout.LayoutParams, LinearLayout.LayoutParams, RadioGroup.LayoutParams, RelativeLayout.LayoutParams, SlidingPaneLayout.LayoutParams, TableLayout.LayoutParams, TableRow.LayoutParams


Android全レイアウトで共通利用できる「XML属性」

 閲覧数:594 投稿日:2014-03-13 更新日:2014-03-30 

XML属性

XML属性名 内容
android:layout_height Viewの高さ
android:layout_width Viewの幅


コード例


「android:layout_height / android:layout_width」で指定可能な値
・数値 dp,sp,px
・match_parent(fill_parent) / wrap_content
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="hello_world" />

</RelativeLayout>


Android全レイアウトで共通利用できる「定数一覧」

 閲覧数:435 投稿日:2014-03-13 更新日:2014-03-30 

FILL_PARENT


「ビューを設定する画面の幅」又は「高さ」いっぱいに大きさを拡大
・親ビューのサイズに合わせる
・親Viewと同じサイズに調整
・残っている領域すべて使って配置
・最大
・親要素のサイズまで大きくなるよう拡大(但しパディング分を引く)
・MATCH_PARENTと同じ意味
・Android2.2(レベル8)未満の書き方
・非推奨だが、FILL_PARENTは引き続き利用可能


MATCH_PARENT


FILL_PARENT名称は、API Level 8以降、MATCH_PARENTへ変更された
・API Android2.2(レベル8)以降は、FILL_PARENTではなくMATCH_PARENT推奨


WRAP_CONTENT


自身のコンテンツサイズに合わせる
・コンテンツを表示するのに十分なサイズに調整
・表示のために必要となるサイズに自動的に幅又は高さを調整
・ウィジェットの領域を適当に調整して配置
・最小
・コンテンツを表示できる最小の大きさ


LinearLayout.LayoutParamsクラス

ViewGroup.MarginLayoutParamsクラス

コメント投稿(ログインが必要)