鴻蒙OS ComponentTransition

2022-09-20 16:27 更新

ComponentTransition

java.lang.Object

|---ohos.agp.components.ComponentTransition

public class ComponentTransition
extends Object

為 ComponentContainer 對(duì)象的布局更改提供動(dòng)畫(huà)。

要在布局容器上執(zhí)行布局轉(zhuǎn)換,請(qǐng)創(chuàng)建一個(gè) ComponentTransition 對(duì)象,然后使用 ComponentContainer#setComponentTransition 設(shè)置一個(gè) ComponentContainer 對(duì)象。

字段摘要

修飾符和類(lèi)型 字段 描述
static int CHANGING 指示在由布局修改更改的組件上運(yùn)行的動(dòng)畫(huà),而不是通過(guò)在布局容器中添加或刪除組件。
static int OTHERS_GONE 指示在組件上運(yùn)行的動(dòng)畫(huà),因?yàn)樗鼈兊年P(guān)聯(lián)組件之一從 ComponentContainer 中消失而發(fā)生更改。
static int OTHERS_SHOW 指示在組件上運(yùn)行的動(dòng)畫(huà),因?yàn)樗鼈兊年P(guān)聯(lián)組件之一出現(xiàn)在 ComponentContainer 中而發(fā)生更改。
static int SELF_GONE 表示當(dāng)組件從 ComponentContainer 中消失時(shí)在組件上運(yùn)行的動(dòng)畫(huà)。
static int SELF_SHOW 表示當(dāng)組件出現(xiàn)在 ComponentContainer 中時(shí)在組件上運(yùn)行的動(dòng)畫(huà)。

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

構(gòu)造函數(shù) 描述
ComponentTransition() 用于創(chuàng)建 ComponentTransition 實(shí)例的默認(rèn)構(gòu)造函數(shù)。

方法總結(jié)

修飾符和類(lèi)型 方法 描述
void addTransitionType(int type) 為 ComponentTransition 對(duì)象啟用過(guò)渡類(lèi)型。
AnimatorProperty getAnimatorProperty(int type) 獲取指定轉(zhuǎn)場(chǎng)類(lèi)型的組件屬性動(dòng)畫(huà)器。
boolean hasTransitionType(int type) 檢查是否為 ComponentTransition 對(duì)象啟用了指定的過(guò)渡類(lèi)型。
void release() 釋放一個(gè) ComponentTransition 對(duì)象。
void removeTransitionType(int type) 從 ComponentTransition 對(duì)象中移除過(guò)渡類(lèi)型。
void setAnimatorProperty(int type, AnimatorProperty animator) 設(shè)置指定轉(zhuǎn)換類(lèi)型的可自定義組件屬性動(dòng)畫(huà)器。
void setTransitionTypeDuration(int type, int duration) 設(shè)置指定過(guò)渡類(lèi)型動(dòng)畫(huà)的持續(xù)時(shí)間。
從類(lèi) java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

字段詳細(xì)信息

CHANGING

public static final int CHANGING

指示在由布局修改更改的組件上運(yùn)行的動(dòng)畫(huà),而不是通過(guò)在布局容器中添加或刪除組件。

默認(rèn)情況下,此轉(zhuǎn)換類(lèi)型被禁用。 您可以調(diào)用 addTransitionType(int) 來(lái)啟用它。

OTHERS_GONE

public static final int OTHERS_GONE

指示在組件上運(yùn)行的動(dòng)畫(huà),因?yàn)樗鼈兊年P(guān)聯(lián)組件之一從 ComponentContainer 中消失而發(fā)生更改。

OTHERS_SHOW

public static final int OTHERS_SHOW

指示在組件上運(yùn)行的動(dòng)畫(huà),因?yàn)樗鼈兊年P(guān)聯(lián)組件之一出現(xiàn)在 ComponentContainer 中而發(fā)生更改。

SELF_GONE

public static final int SELF_GONE

表示當(dāng)組件從 ComponentContainer 中消失時(shí)在組件上運(yùn)行的動(dòng)畫(huà)。

SELF_SHOW

public static final int SELF_SHOW

表示當(dāng)組件出現(xiàn)在 ComponentContainer 中時(shí)在組件上運(yùn)行的動(dòng)畫(huà)。

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

ComponentTransition

public ComponentTransition()

用于創(chuàng)建 ComponentTransition 實(shí)例的默認(rèn)構(gòu)造函數(shù)。

方法詳情

release

public void release()

釋放一個(gè) ComponentTransition 對(duì)象。

addTransitionType

public void addTransitionType(int type)

為 ComponentTransition 對(duì)象啟用過(guò)渡類(lèi)型。

過(guò)渡類(lèi)型包括 SELF_SHOW、OTHERS_SHOW、OTHERS_GONE、SELF_GONE 和 CHANGING。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
type 指示要啟用的轉(zhuǎn)換類(lèi)型。

removeTransitionType

public void removeTransitionType(int type)

從 ComponentTransition 對(duì)象中移除過(guò)渡類(lèi)型。

默認(rèn)情況下,啟用除 CHANGING 之外的所有轉(zhuǎn)換類(lèi)型。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
type 指示要?jiǎng)h除的轉(zhuǎn)換類(lèi)型。

hasTransitionType

public boolean hasTransitionType(int type)

檢查是否為 ComponentTransition 對(duì)象啟用了指定的過(guò)渡類(lèi)型。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
type 表示指定的過(guò)渡類(lèi)型。

返回:

如果添加了指定的過(guò)渡類(lèi)型,則返回 true; 否則返回 false。

setTransitionTypeDuration

public void setTransitionTypeDuration(int type, int duration)

設(shè)置指定過(guò)渡類(lèi)型動(dòng)畫(huà)的持續(xù)時(shí)間。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
type 表示指定的轉(zhuǎn)場(chǎng)類(lèi)型,可以是SELF_SHOW、OTHERS_SHOW、OTHERS_GONE、SELF_GONE或CHANGING。
duration 指示過(guò)渡動(dòng)畫(huà)的持續(xù)時(shí)間,以毫秒為單位。

setAnimatorProperty

public void setAnimatorProperty(int type, AnimatorProperty animator)

設(shè)置指定轉(zhuǎn)換類(lèi)型的可自定義組件屬性動(dòng)畫(huà)器。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
type 表示指定的轉(zhuǎn)場(chǎng)類(lèi)型,可以是SELF_SHOW、OTHERS_SHOW、OTHERS_GONE、SELF_GONE或CHANGING。
animator 表示組件屬性動(dòng)畫(huà)器。

getAnimatorProperty

public AnimatorProperty getAnimatorProperty(int type)

獲取指定轉(zhuǎn)場(chǎng)類(lèi)型的組件屬性動(dòng)畫(huà)器。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
type 表示指定的轉(zhuǎn)場(chǎng)類(lèi)型,可以是SELF_SHOW、OTHERS_SHOW、OTHERS_GONE、SELF_GONE或CHANGING。

返回:

返回指定轉(zhuǎn)場(chǎng)類(lèi)型的AnimatorProperty對(duì)象; 否則返回 null。

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

掃描二維碼

下載編程獅App

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

編程獅公眾號(hào)