- 動態切換圖像
- 陣營母語
- 開發模式
- 的Android
問題
- 圖像在開發模式期間出現時會淡入。這是一個問題,因爲我正在開發和調整具有實際淡入效果的圖像動畫。是否可以禁用淡入效果?
嘗試
- 切換到發佈模式。在開發過程中工作但不合適。
- 最小化圖像文件大小。沒有明顯的差異。
- 最小化圖像顯示大小。沒有明顯的差異。
問題
嘗試
我設法通過包裝我<Image />
使用自定義ViewGroupManager
和之前的圖像被添加到自定義ViewGroup
與反思設置ReactImageView.mFadeDuration
爲零,以防止褪色動畫。 編輯:但這顯示圖像時增加了一個明顯的延遲:(有實際上是沒有延遲
事情是這樣的:
public class NoFadeImageWrapper extends ViewGroup {
public NoFadeImageWrapper(Context context) {
super(context);
}
@Override
public void onViewAdded(View child) {
if (child instanceof ReactImageView) {
((ReactImageView) child).setFadeDuration(0);
ReflectionUtils.setField(child, "mIsDirty", true);
}
super.onViewAdded(child);
}
}
ReflectionUtils.setField
實現:
public class ReflectionUtils {
public static void setField(Object obj, String name, Object value) {
try {
Field field = getField(obj.getClass(), name);
if (field == null) {
return;
}
field.setAccessible(true);
field.set(obj, value);
} catch (Exception e) {
e.printStackTrace();
}
}
}
你可以發佈你正在使用 –
一些代碼是否使用Animated.spring()在頁面的任何地方?我有一個問題,在視覺樹中的一個組件中使用它,意味着頁面上的每個元素都會獲得淡入淡出動畫。在我確定它來自哪裏之前,讓我有點瘋狂。 –
你有沒有想過這個? –