鴻蒙OS MagicLayout.LayoutConfig

2022-09-27 09:48 更新

MagicLayout.LayoutConfig

java.lang.Object

|---ohos.agp.components.ComponentContainer.LayoutConfig

|---|---ohos.agp.components.MagicLayout.LayoutConfig

public static class MagicLayout.LayoutConfig
extends ComponentContainer.LayoutConfig

指定 MagicLayout 中組件的布局參數(shù)。

Since:

5

字段摘要

修飾符和類型 字段 描述
int referenceSize 表示換行參考大小。
static int UNSPECIFIED_HIDE_PRIORITY 表示默認(rèn)隱藏優(yōu)先級(jí)。
static int UNSPECIFIED_REFERENCE_SIZE 指示換行參考尺寸的默認(rèn)值,它等于組件的寬度及其邊距。
從類 ohos.agp.components.ComponentContainer.LayoutConfig 繼承的字段
height, MATCH_CONTENT, MATCH_PARENT, width

構(gòu)造函數(shù)摘要

構(gòu)造函數(shù) 描述
LayoutConfig() 用于創(chuàng)建 LayoutConfig 實(shí)例的默認(rèn)構(gòu)造函數(shù),默認(rèn)寬度和高度為 ComponentContainer.LayoutConfig#MATCH_CONTENT。
LayoutConfig(int width, int height) 用于創(chuàng)建具有指定寬度和高度的 LayoutConfig 實(shí)例的構(gòu)造函數(shù)。
LayoutConfig(ComponentContainer.LayoutConfig source) 用于創(chuàng)建 LayoutConfig 實(shí)例的構(gòu)造函數(shù),使用父布局的參數(shù)。
LayoutConfig(MagicLayout.LayoutConfig source) 用于創(chuàng)建 LayoutConfig 實(shí)例的構(gòu)造函數(shù),使用當(dāng)前 MagicLayout 的參數(shù)(包括寬度、高度、填充、邊距、對(duì)齊方式和換行參考大小)。
LayoutConfig(Context context, AttrSet attrSet) 用于創(chuàng)建具有指定應(yīng)用程序上下文和屬性集的 LayoutConfig 實(shí)例的構(gòu)造函數(shù)。

方法總結(jié)

修飾符和類型 方法 描述
void applyToComponent(Component component)
int getHidePriority() 獲取 MagicLayout 中組件的隱藏優(yōu)先級(jí)。
float getLayoutWeight() 獲取 MagicLayout 中組件的權(quán)重。
int getMaxScaleHeight() 獲取 MagicLayout 中縮放組件的最大高度。
int getMaxScaleWidth() 獲取 MagicLayout 中縮放組件的最大寬度。
int getMinScaleHeight() 獲取 MagicLayout 中縮放組件的最小高度。
int getMinScaleWidth() 獲取 MagicLayout 中縮放組件的最小寬度。
float getScaleRatioOfParentHeight() 獲取縮放組件的高度與其父 MagicLayout 高度的比率。
float getScaleRatioOfParentWidth() 獲取縮放組件的寬度與其父 MagicLayout 寬度的比率。
void setHidePriority(int hidePriority) 設(shè)置 MagicLayout 中組件的隱藏優(yōu)先級(jí)。
void setLayoutWeight(float layoutWeight) 設(shè)置 MagicLayout 中組件的權(quán)重。
void setMaxScaleHeight(int maxScaleHeight) 設(shè)置 MagicLayout 中縮放組件的最大高度。
void setMaxScaleWidth(int maxScaleWidth) 設(shè)置 MagicLayout 中縮放組件的最大寬度。
void setMinScaleHeight(int minScaleHeight) 設(shè)置 MagicLayout 中縮放組件的最小高度。
void setMinScaleWidth(int minScaleWidth) 設(shè)置 MagicLayout 中縮放組件的最小寬度。
void setScaleRatioOfParentHeight(float heightRatio) 設(shè)置縮放組件的高度與其父 MagicLayout 高度的比率。
void setScaleRatioOfParentWidth(float widthRatio) 設(shè)置縮放組件的寬度與其父 MagicLayout 的寬度的比率。
從類 ohos.agp.components.ComponentContainer.LayoutConfig 繼承的方法
clone, getHorizontalEndMargin, getHorizontalStartMargin, getLayoutDirection, getMarginBottom, getMarginLeft, getMarginRight, getMargins, getMarginsLeftAndRight, getMarginsTopAndBottom, getMarginTop, isMarginsRelative, setMarginBottom, setMarginLeft, setMarginRight, setMargins, setMarginsLeftAndRight, setMarginsRelative, setMarginsTopAndBottom, setMarginTop
從類 java.lang.Object 繼承的方法
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

字段詳細(xì)信息

UNSPECIFIED_HIDE_PRIORITY

public static final int UNSPECIFIED_HIDE_PRIORITY

表示默認(rèn)隱藏優(yōu)先級(jí)。

Since:

7

UNSPECIFIED_REFERENCE_SIZE

public static final int UNSPECIFIED_REFERENCE_SIZE

指示換行參考尺寸的默認(rèn)值,它等于組件的寬度及其邊距。

Since:

5

referenceSize

public int referenceSize

表示換行參考大小。 如果新組件的換行參考尺寸與當(dāng)前行中現(xiàn)有組件的換行參考尺寸之和超過布局的總寬度,則該組件將被放置到下一行。

Since:

5

構(gòu)造函數(shù)詳細(xì)信息

LayoutConfig

public LayoutConfig()

用于創(chuàng)建 LayoutConfig 實(shí)例的默認(rèn)構(gòu)造函數(shù),默認(rèn)寬度和高度為 ComponentContainer.LayoutConfig#MATCH_CONTENT。

Since:

5

LayoutConfig

public LayoutConfig(Context context, AttrSet attrSet)

用于創(chuàng)建具有指定應(yīng)用程序上下文和屬性集的 LayoutConfig 實(shí)例的構(gòu)造函數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
context 指示應(yīng)用程序上下文。
attrSet 指示要使用的屬性集。

Since:

5

LayoutConfig

public LayoutConfig(int width, int height)

用于創(chuàng)建具有指定寬度和高度的 LayoutConfig 實(shí)例的構(gòu)造函數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
width 表示要設(shè)置的寬度。
height 表示要設(shè)置的高度。

Since:

5

LayoutConfig

public LayoutConfig(ComponentContainer.LayoutConfig source)

用于創(chuàng)建 LayoutConfig 實(shí)例的構(gòu)造函數(shù),使用父布局的參數(shù)。

使用填充、邊距、對(duì)齊模式和換行參考大小(由 referenceSize 表示)的默認(rèn)值。

參數(shù):

參數(shù)名稱 參數(shù)描述
source 表示父布局的參數(shù)。

Since:

5

LayoutConfig

public LayoutConfig(MagicLayout.LayoutConfig source)

用于創(chuàng)建 LayoutConfig 實(shí)例的構(gòu)造函數(shù),使用當(dāng)前 MagicLayout 的參數(shù)(包括寬度、高度、填充、邊距、對(duì)齊方式和換行參考大?。?。

參數(shù):

參數(shù)名稱 參數(shù)描述
source 表示當(dāng)前MagicLayout的參數(shù)。

Since:

5

方法詳情

getScaleRatioOfParentWidth

public float getScaleRatioOfParentWidth()

獲取縮放組件的寬度與其父 MagicLayout 寬度的比率。

返回:

返回寬度比率。

Since:

7

setScaleRatioOfParentWidth

public void setScaleRatioOfParentWidth(float widthRatio)

設(shè)置縮放組件的寬度與其父 MagicLayout 的寬度的比率。

參數(shù):

參數(shù)名稱 參數(shù)描述
widthRatio 表示寬度比例,范圍為[0.0, 1.0]。

Since:

7

getScaleRatioOfParentHeight

public float getScaleRatioOfParentHeight()

獲取縮放組件的高度與其父 MagicLayout 高度的比率。

返回:

返回高度比。

Since:

7

setScaleRatioOfParentHeight

public void setScaleRatioOfParentHeight(float heightRatio)

設(shè)置縮放組件的高度與其父 MagicLayout 高度的比率。

參數(shù):

參數(shù)名稱 參數(shù)描述
heightRatio 表示高度比,范圍[0.0, 1.0]。

Since:

7

getMaxScaleWidth

public int getMaxScaleWidth()

獲取 MagicLayout 中縮放組件的最大寬度。

返回:

返回縮放組件的最大寬度。

Since:

7

setMaxScaleWidth

public void setMaxScaleWidth(int maxScaleWidth)

設(shè)置 MagicLayout 中縮放組件的最大寬度。

參數(shù):

參數(shù)名稱 參數(shù)描述
maxScaleWidth 表示縮放組件的最大寬度。

Since:

7

getMinScaleWidth

public int getMinScaleWidth()

獲取 MagicLayout 中縮放組件的最小寬度。

返回:

返回縮放組件的最小寬度。

Since:

7

setMinScaleWidth

public void setMinScaleWidth(int minScaleWidth)

設(shè)置 MagicLayout 中縮放組件的最小寬度。

參數(shù):

參數(shù)名稱 參數(shù)描述
minScaleWidth 表示縮放組件的最小寬度。

Since:

7

getMaxScaleHeight

public int getMaxScaleHeight()

獲取 MagicLayout 中縮放組件的最大高度。

返回:

返回縮放組件的最大高度。

Since:

7

setMaxScaleHeight

public void setMaxScaleHeight(int maxScaleHeight)

設(shè)置 MagicLayout 中縮放組件的最大高度。

參數(shù):

參數(shù)名稱 參數(shù)描述
maxScaleHeight 表示縮放組件的最大高度。

Since:

7

getMinScaleHeight

public int getMinScaleHeight()

獲取 MagicLayout 中縮放組件的最小高度。

返回:

返回縮放組件的最小高度。

Since:

7

setMinScaleHeight

public void setMinScaleHeight(int minScaleHeight)

設(shè)置 MagicLayout 中縮放組件的最小高度。

參數(shù):

參數(shù)名稱 參數(shù)描述
minScaleHeight 指示縮放組件的最小高度。

Since:

7

setLayoutWeight

public void setLayoutWeight(float layoutWeight)

設(shè)置 MagicLayout 中組件的權(quán)重。

參數(shù):

參數(shù)名稱 參數(shù)描述
layoutWeight 表示組件的重量。

Since:

7

getLayoutWeight

public float getLayoutWeight()

獲取 MagicLayout 中組件的權(quán)重。

返回:

組件的重量。

Since:

7

setHidePriority

public void setHidePriority(int hidePriority)

設(shè)置 MagicLayout 中組件的隱藏優(yōu)先級(jí)。 較小的值表示較高的優(yōu)先級(jí)。

參數(shù):

參數(shù)名稱 參數(shù)描述
hidePriority 表示組件的隱藏優(yōu)先級(jí)。

Since:

7

getHidePriority

public int getHidePriority()

獲取 MagicLayout 中組件的隱藏優(yōu)先級(jí)。

返回:

組件的隱藏優(yōu)先級(jí)。

Since:

7

applyToComponent

public void applyToComponent(Component component)

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)