亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

目錄 搜尋
android Manifest Manifest.permission Manifest.permission_group android.accessibilityservice AccessibilityService android.accounts Account android.app NotificationManager android.bluetooth BluetoothAdapter BluetoothClass BluetoothClass.Device BluetoothClass.Device.Major BluetoothClass.Service BluetoothDevice BluetoothServerSocket BluetoothSocket android.content SharedPreferences android.database.sqlite SQLiteCursorDriver SQLiteOpenHelper android.graphics Bitmap android.location LocationListener Geocoder GpsStatus GpsStatus.Listener GpsStatus.NmeaListener GpsSatellite android.media AudioFormat AsyncPlayer AudioRecord AudioRecord.OnRecordPositionUpdateListener ThumbnailUtils AudioManager android.net TrafficStats MailTo LocalSocket android.os AsyncTask AsyncTask.Status CountDownTimer Message MessageQueue HandlerThread android.text Html android.util JsonWriter android.view ContextMenu ContextMenu.ContextMenuInfo Display ViewManager View ViewStub ViewTreeObserver ViewParent WindowManager GestureDetector Gravity MenuInflater ScaleGestureDetector SoundEffectConstants android.view.inputmethod InputConnection InputMethod InputMethodSession BaseInputConnection InputMethodManager android.widget AbsListView AbsListView.LayoutParams AbsListView.OnScrollListener AbsListView.RecyclerListener AbsoluteLayout AbsoluteLayout.LayoutParams AbsSeekBar AbsSpinner AdapterView AdapterView.AdapterContextMenuInfo AdapterView.OnItemLongClickListener AdapterView.OnItemSelectedListener AdapterView.OnItemClickListener AnalogClock BaseAdapter BaseExpandableListAdapter Button CheckBox CheckedTextView Checkable Chronometer Chronometer.OnChronometerTickListener CompoundButton CompoundButton.OnCheckedChangeListener CursorAdapter CursorTreeAdapter DatePicker DatePicker.OnDateChangedListener DialerFilter DigitalClock EditText Filter Filter.FilterListener Filter.FilterResults ExpandableListAdapter ExpandableListView.OnChildClickListener ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupCollapseListener ExpandableListView.OnGroupExpandListener Filterable Gallery Gallery.LayoutParams GridView GridLayout GridLayout.Alignment RadioGroup ImageView ImageView.ScaleType HorizontalScrollView ImageButton ImageSwitcher FilterQueryProvider ListAdapter ListView MediaController MultiAutoCompleteTextView MultiAutoCompleteTextView.CommaTokenizer MultiAutoCompleteTextView.Tokenizer QuickContactBadge RadioButton RatingBar RatingBar.OnRatingBarChangeListener RelativeLayout RemoteViews ResourceCursorAdapter ResourceCursorTreeAdapter Scroller ScrollView SearchView SearchView.OnCloseListener SearchView.OnQueryTextListener SearchView.OnSuggestionListener SeekBar SeekBar.OnSeekBarChangeListener SimpleAdapter SimpleAdapter.ViewBinder SimpleCursorAdapter SimpleCursorAdapter.CursorToStringConverter SimpleCursorAdapter.ViewBinder SimpleCursorTreeAdapter SimpleCursorTreeAdapter.ViewBinder SimpleExpandableListAdapter SlidingDrawer SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener SlidingDrawer.OnDrawerScrollListener Spinner SpinnerAdapter WrapperListAdapter TabHost TabHost.TabSpec TextView TimePicker TimePicker.OnTimeChangedListener Toast TableLayout TableLayout.LayoutParams TableRow TableRow.LayoutParams TabWidget TextSwitcher ToggleButton TwoLineListItem VideoView ViewAnimator ViewFlipper ViewSwitcher ViewSwitcher.ViewFactory ZoomButtonsController ZoomButtonsController.OnZoomListener ZoomButton ZoomControls dalvik.system DexFile
文字

GridLayout

版本:Android 4.0 r1

?

結(jié)構(gòu)

繼承關(guān)系

public class GridLayout extends ViewGroup

????????

java.lang.Object

android.view.View

???????? android.view.ViewGroup

?????????????????? android.widget.GridLayout

?

類概述

?(摘自這里。)

該布局把子視圖存放在一個矩形網(wǎng)格中。

網(wǎng)格是由被無數(shù)虛細線分割成多個單元格的可視區(qū)域組成。貫穿整個API的網(wǎng)格線通過網(wǎng)格索引數(shù)來指定。一個N列的網(wǎng)格在運行中包含0N N+1個索引,不管怎么配置GridLayout 網(wǎng)格索引0是固定網(wǎng)格容器的前邊距,索引N是固定容器的后邊距(考慮后填充)。

?

行和列的規(guī)格

rowSpeccolumnSpec布局參數(shù)的定義后,子視圖占用一個或者多個連續(xù)單元格,每個規(guī)范是定義被占用的行或列的設(shè)置和子視圖在單元格是如何對齊。盡管各個單元格在一個GridLayout中不重疊,GridLayout沒有阻止子視圖被定義為占據(jù)相同的單元格或者單元格組。然而在這種情況下,也不能保證子視圖在布局操作完成后自己不會重疊。

?

默認單元格分配

如果一個子視圖沒有指定占據(jù)的行和列索引,GridLayout會自動指定單元格位置,包括:方向,行數(shù)和列數(shù)的屬性。

?

空間(Place)

子視圖之間的空間可能會通過使用專用的空間視圖的實例,或通過設(shè)置leftMargintopMargin,rightMarginbottomMargin布局參數(shù)后指定。當設(shè)置為useDefaultMargins屬性,根據(jù)當前平臺的用戶界面風格,子視圖周圍的默認邊距將自動分配。每個被定義的邊距可通過分配到相應(yīng)的布局參數(shù)來獨立覆蓋。默認值通常在不同組成部分會產(chǎn)生一個合理的間距,但在不同平臺版本之間可能會改變。

?

多余的空間分布

GridLayout的多余的空間分布是基于優(yōu)先級,而不是根據(jù)比例。

一個子視圖的的伸展程度通過其行和列的組的對其屬性推算(這是典型的設(shè)置子視圖的布局參數(shù)gravity屬性)。如果對齊是沿著給定的軸定義,那么該組件在這個方向具有靈活性。如果沒有對齊,相反組件會缺乏靈活性。

多個組件在同一行或列組被認為平行的。如果組中所有在內(nèi)的組件是靈活的,那么這個小組是靈活的。位置在一個共同的邊界兩側(cè)的行和列組,反而認為采取同一系列。如果復(fù)合組的一個元素是靈活的,則這個復(fù)合組是靈活的。

為了使一列伸展,確保所有的組件,它里面定義一個的gravity屬性。為了防止從列伸展,確保列中的組成部分之一沒有定義的gravity屬性。

靈活性的原則并不能完全的消除歧義,推薦GridLayout中的算法更接近其右側(cè)和底邊的行和列。

?

局限性

GridLayout的不提供支持空間(weight)分配的原則,空間分配界定。在一般情況下,可以配置一個GridLayout多余的空間分布在多個行或列之間的不相同的比例。

一些常見的適用情況,如下:將等量的周圍空間中的一個組成部分單元格組;使用居中對齊(或gravity屬性)。對于完全控制對或列中多余的空間分布;使用的LinearLayout子視圖約束相關(guān)的單元格組的組成部分。當使用這些技術(shù),記住,單元格組可能定義重疊。

GridLayout的使用布局參數(shù)的完整描述GridLayout.LayoutParams

?

XML屬性

屬性名稱

描述

android:alignmentMode

當設(shè)置alignMargins,使視圖的外邊界之間進行校準,定義其邊距,當設(shè)置alignBounds,使視圖的邊界之間進行校準,默認設(shè)置alignMargins

常量

備注

alignBounds

0

對齊子視圖邊界。

alignMargins

1

對齊子視圖邊距。

android:columnCount

自動定位子視圖時創(chuàng)建的最大列數(shù)

android:columnOrderPreserved

當設(shè)置為true,使列邊界顯示的順序和列索引的順序相同。默認是true。

android:orientation

Orientation屬性在布局時候不被使用,它僅當子視圖布局參數(shù)沒有指定的時候分配行和列,GridLayout在這種情況下和LinearLayout使用方法一樣,根據(jù)標志的值將所有組件放在單個行或者放在當個列中。在水平情況下,當一行的所有列都填充滿時,columnCount屬性額外提供創(chuàng)建新行。同樣在垂直情況下,rowCount屬性有相同的作用,默認是水平的。

常量

備注

horizontal

0

定義水平部件。

vertical

1

定義垂直部件。

android:rowCount

自動定位子視圖時創(chuàng)建的最大行數(shù)

android:rowOrderPreserved

當設(shè)置為true,使行邊界顯示的順序和行索引的順序相同。默認是true

android:useDefaultMargins

當設(shè)置ture,當沒有指定視圖的布局參數(shù)時,告訴GridLayout使用默認的邊距。默認值是false。

?

常量

類型

屬性名稱

描述

int

ALIGN_BOUNDS

這是alignmentMode的常量,當alignmentMode設(shè)置成ALIGN_BOUNDS,每個組件之間的原始視圖邊界邊距對齊:即組件的區(qū)域通過下面分隔:頂部,左側(cè),底部和右側(cè)的屬性。默認值:0

int

ALIGN_MARGINS

這是alignmentMode的常量。當alignmentMode設(shè)置ALIGN_MARGINS,每個視圖的邊界向外延伸,根據(jù)他們的邊距,產(chǎn)生的矩形邊距對齊。默認值:1

int

HORIZONTAL

水平方向。默認值:0

int

UNDEFINED

常數(shù)用于表示一個不確定的值。該字段可以使用這個值來表示他們的值觀尚未確定。同樣的方法可以返回這個值,表明沒有能實現(xiàn)返回的合適值,該常數(shù)的值(目前MIN_VALUE)是為了避免可能不知道其標志的有效值之間的混淆。

int

VERTICAL

垂直方向。默認值:1

?

字段

public static final?GridLayout.Alignment

屬性名稱

描述

BASELINE

表示一個視圖應(yīng)該和在同一單元格組的其他視圖基線對齊,這個常量僅用做rowSpecs對齊

BOTTOM

表示一個視圖應(yīng)該和在同一單元格組的其他視圖底部邊距對齊。

CENTER

表示一個視圖應(yīng)該和在同一單元格組的其他視圖居中對齊,此常數(shù)可用于rowSpecscolumnSpecs。

FILL

表示視圖應(yīng)該擴大以填充其單元格組。此常數(shù)可用于rowSpecscolumnSpecs。

LEFT

表示一個視圖應(yīng)該和在同一單元格組的其他視圖左邊距對齊。

RIGHTT

表示一個視圖應(yīng)該和在同一單元格組的其他視圖右邊距對齊。

TOP

表示一個視圖應(yīng)該和在同一單元格組的其他視圖上邊距對齊。

?

?

公共方法

public?GridLayout.LayoutParams?generateLayoutParams?(AttributeSet?attrs)

在提供的屬性集基礎(chǔ)上返回一個新的布局參數(shù)設(shè)置。

參數(shù)

attrs?????????????????? 創(chuàng)建布局參數(shù)的屬性

返回值

?????????????????? ViewGroup.LayoutParams實例或者他的派生實例

?

public int?getAlignmentMode?()

返回對齊方式.

相關(guān)XML屬性

android:alignmentMode

返回值

對齊方式; ?ALIGN_BOUNDS?或者?ALIGN_MARGINS

參見

ALIGN_BOUNDS

ALIGN_MARGINS

setAlignmentMode(int)

?

public int?getColumnCount?()

返回當前的列數(shù)。通過?setColumnCountint)方法最后一次設(shè)置的值,如果沒有這樣的值被設(shè)置,返回在columnSpec定義中的每一個上限的最大值。

相關(guān)XML屬性

android:columnCount

返回值

當前的列數(shù)

參見

setColumnCount(int)

columnSpec

?

public int?getOrientation?()

返回當前方向。

相關(guān)XML屬性

android:orientation

???????? 返回值

?HORIZONTAL?或者?VERTICAL

參見

setOrientation(int)

?

public int?getRowCount?()

返回當前的行數(shù)。通過?setRowCountint)方法最后一次設(shè)置的值,如果沒有這樣的值被設(shè)置,返回在rowSpec定義中的每一個上限的最大值。

相關(guān)XML

android:rowCount

返回值

返回當前的行數(shù)。

參見

setRowCount(int)

rowSpec

?

public boolean?getUseDefaultMargins?()

返回是否GridLayout分配時候,沒有相應(yīng)布局參數(shù)定義的默認邊距。

相關(guān)XML屬性

android:useDefaultMargins

返回值

如果分配默認的邊距返回ture

參見

setUseDefaultMargins(boolean)

?

public boolean isColumnOrderPreserved ()

返回是否通過表格索引順序定制列邊界。

相關(guān)XML屬性

android:columnOrderPreserved

返回值

如果列邊界按照索引的順序顯示返回ture,否則返回false

參見

setColumnOrderPreserved(boolean)

?

public boolean isRowOrderPreserved ()

返回是否通過表格索引順序定制行邊界

相關(guān)XML屬性

android:rowOrderPreserved

返回值

如果行邊界按照索引順序顯示返回ture,否則返回false

參見

setRowOrderPreserved(boolean)

?

public void requestLayout ()

當無效的視圖布局發(fā)生變化時候調(diào)用它,將通過視圖樹進行布局傳遞。

?

public void setAlignmentMode (int alignmentMode)

設(shè)置該容器中所有子視圖之間的對齊方式

默認的值是ALIGN_MARGINS.

相關(guān)XML屬性

android:alignmentMode

參數(shù)

alignmentMode?????? ALIGN_BOUNDS 或者 ALIGN_MARGINS

參見

ALIGN_BOUNDS

ALIGN_MARGINS

getAlignmentMode()

?

public void setColumnCount (int columnCount)

列數(shù)是僅用于當沒有一個布局參數(shù)指定時候,生成默認的列/行索引。

相關(guān)XML屬性

android:columnCount

參數(shù)

columnCount?? 列的數(shù)量.

參見

getColumnCount()

columnSpec

?

public void setColumnOrderPreserved (boolean columnOrderPreserved)

當此屬性為true,GridLayout的是被迫使他們相關(guān)的網(wǎng)格指數(shù)在視圖中以升序順序放置列的邊界。

當此屬性是falseGridLayout是放置在任何最適合給定的約束水平列邊界的順序。

此屬性的默認值是true

相關(guān)XML屬性

android:columnOrderPreserved

參數(shù)

columnOrderPreserved?? ture是被迫使他們相關(guān)的網(wǎng)格指數(shù)在視圖中以升序順序放置列的邊界。

參見

isColumnOrderPreserved()

?

public void setOrientation (int orientation)

Orientation是僅用于當沒有一個布局參數(shù)指定時候,生成默認的列/行索引

默認的屬性值是HORIZONTAL

相關(guān)XML屬性

android:orientation

參數(shù)

orientation?????? HORIZONTAL 或者 VERTICAL

參見

getOrientation()

?

public void setRowCount (int rowCount)

RowCount是僅用于當沒有一個布局參數(shù)指定時候,生成默認的列/行索引

相關(guān)XML屬性

android:rowCount

參數(shù)

rowCount???????? 行數(shù)

參見

getRowCount()

rowSpec

?

public void setRowOrderPreserved (boolean rowOrderPreserved)

當此屬性為true,GridLayout是強制他們相關(guān)的網(wǎng)格指數(shù)在視圖中以升序順序放置行的邊界。

當此屬性是false,GridLayout是放置在任何最適合給定的約束水平行邊界的順序。

此屬性的默認值是true。

相關(guān)XML屬性

android:rowOrderPreserved

參數(shù)

rowOrderPreserved ture是強制他們相關(guān)的網(wǎng)格指數(shù)在視圖中以升序順序放置列的邊界。

參見

isRowOrderPreserved ()

?

public void setUseDefaultMargins (boolean useDefaultMargins)

當設(shè)置為true, GridLayout根據(jù)子視圖的的視覺特征分配在子視圖周圍的默認邊距,每個定義的邊距,可獨立分配到相應(yīng)的布局參數(shù)覆蓋。

如果為false,所有邊距的默認值是零。

當設(shè)置為true時,考慮設(shè)置的alignmentMode屬性值ALIGN_BOUNDS。

此屬性的默認值是false。

相關(guān)XML屬性

android:useDefaultMargins

參數(shù)

useDefaultMargins 使用true分配默認的邊距

參見

getUseDefaultMargins()

setAlignmentMode(int)

?

public static GridLayout.Spec spec (int start, GridLayout.Alignment alignment)

返回一個Spec其中:

l?? spec.span = [start, start + 1]

l?? spec.alignment = alignment

參數(shù)

start???????? the ????????? 開始索引

alignment???????? 對齊方式

?

public static GridLayout.Spec spec (int start, int size)

返回一個Spec,其中:

l?? spec.span = [start, start + size]

參數(shù)

start?????????????????? 開始位置

size?????????? 大小

?

public static GridLayout.Spec spec (int start, int size, GridLayout.Alignment alignment)

返回一個Spec,其中:

l?? spec.span = [start, start + size]

l?? spec.alignment = alignment

參數(shù)

start??????????????????????????? 開始位置

size???????????????????? 大小

alignment???????? 對齊方式

?

public static GridLayout.Spec spec (int start)

返回一個Spec,其中:

l?? spec.span = [start, start + 1]

參數(shù)

start??????????????????????????? 開始索引

?

保護方法

protected GridLayout.LayoutParams generateDefaultLayoutParams ()

返回一組默認布局參數(shù)。沒有設(shè)置布局參數(shù)執(zhí)行addviewView)時,這些參數(shù)被請求時返回null,并拋出一個異常。

返回值

一組默認布局參數(shù)或者null

?

protected GridLayout.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)

返回一組合法的受支持的布局參數(shù)。當一個ViewGroup傳遞一個布局參數(shù)沒有通過checkLayoutParams(android.view.ViewGroup.LayoutParams)檢測的視圖時,此方法被調(diào)用。此方法會返回一組新的適合當前ViewGroup的布局參數(shù),可能從指定的一組布局參數(shù)中復(fù)制適當?shù)膶傩浴?/span>

參數(shù)

p 被轉(zhuǎn)換成一組適合當前 ViewGroup的布局參數(shù).

返回值

一個ViewGroup.LayoutParams的實例或者其中的一個子節(jié)點

?

補充

???????? 文章精選

?????????????????? Android 4.0新增SpaceGridLayout初談


上一篇: 下一篇: