对于想了解以编程方式停止GIF动画的读者,本文将提供新的信息,我们将详细介绍以编程方式停止gif动画怎么办,并且为您提供关于android–以编程方式调整布局(作为动画)、android–如何以编程方
对于想了解以编程方式停止GIF动画的读者,本文将提供新的信息,我们将详细介绍以编程方式停止gif动画怎么办,并且为您提供关于android – 以编程方式调整布局(作为动画)、android – 如何以编程方式滚动动画、android – 如何通过USB编程方式停止手机充电、ios – 如何以编程方式将编程方式添加到以编程方式创建的UIView?的有价值信息。
本文目录一览:- 以编程方式停止GIF动画(以编程方式停止gif动画怎么办)
- android – 以编程方式调整布局(作为动画)
- android – 如何以编程方式滚动动画
- android – 如何通过USB编程方式停止手机充电
- ios – 如何以编程方式将编程方式添加到以编程方式创建的UIView?
以编程方式停止GIF动画(以编程方式停止gif动画怎么办)
我正在开发一个Twitter应用程序,该应用程序直接从Twitter引用图像。如何防止动画gif播放?
window.stop()
在页面末尾使用不适用于Firefox。
是否有更好的JavaScript技巧?最好对所有浏览器都适用
答案1
小编典典这不是跨浏览器的解决方案,但是可以在Firefox和Opera中使用(不适用于ie8:-/)。采取从这里
[].slice.apply(document.images).filter(is_gif_image).map(freeze_gif);function is_gif_image(i) { return /^(?!data:).*\.gif/i.test(i.src);}function freeze_gif(i) { var c = document.createElement(''canvas''); var w = c.width = i.width; var h = c.height = i.height; c.getContext(''2d'').drawImage(i, 0, 0, w, h); try { i.src = c.toDataURL("image/gif"); // if possible, retain all css aspects } catch(e) { // cross-domain -- mimic original with all its tag attributes for (var j = 0, a; a = i.attributes[j]; j++) c.setAttribute(a.name, a.value); i.parentNode.replaceChild(c, i); }}
android – 以编程方式调整布局(作为动画)
我想在Activity中调整一些布局的大小.
这是主XML的代码:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/top"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#3ee3e3" >
</LinearLayout>
<LinearLayout
android:id="@+id/middle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:id="@+id/bottom"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#fe51e6" >
</LinearLayout>
</LinearLayout>
如您所见,顶部和底部布局高度为0,中间
布局涵盖了所有的地方.
我想以编程方式减少中间布局大小,同时增加顶部
和底部布局大小,直到所有布局具有相同的高度.
我希望它看起来像一个动画.
我该怎么办?
谢谢
解决方法:
我为了类似的目的写了一个ResizeAnimation.它很简单但成本很高.
/**
* an animation for resizing the view.
*/
public class ResizeAnimation extends Animation {
private View mView;
private float mToHeight;
private float mFromHeight;
private float mToWidth;
private float mFromWidth;
public ResizeAnimation(View v, float fromWidth, float fromHeight, float toWidth, float toHeight) {
mToHeight = toHeight;
mToWidth = toWidth;
mFromHeight = fromHeight;
mFromWidth = fromWidth;
mView = v;
setDuration(300);
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float height =
(mToHeight - mFromHeight) * interpolatedTime + mFromHeight;
float width = (mToWidth - mFromWidth) * interpolatedTime + mFromWidth;
LayoutParams p = mView.getLayoutParams();
p.height = (int) height;
p.width = (int) width;
mView.requestLayout();
}
}
android – 如何以编程方式滚动动画
尝试使用setSelection(int pos,Boolean animate),它不工作.
有没有办法重写setSelection()方法.
解决方法
mygallery.onKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT,null);
要么
mygallery.onKeyDown(KeyEvent.KEYCODE_DPAD_LEFT,null);
android – 如何通过USB编程方式停止手机充电
我不会制作一个应用程序,我可以手动停止手机充电,而无需从充电器(通过USB)拔下它,所以我想知道这是否实际上是可能的.
解决方法
是的,可以用rooted手机完成.
需要添加权限android.permission.WRITE_SECURE_SETTINGS.
Google Play上的相同类型的应用:https://play.google.com/store/apps/details?id=com.jim2&hl=en
ios – 如何以编程方式将编程方式添加到以编程方式创建的UIView?
secondview = [[UIView alloc] initWithFrame:self.view.frame]; [secondview setBackgroundColor: [UIColor yellowColor]]; secondview.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:secondview];
然后在viewDidAppear中,我添加了这个视图的约束:
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:secondview attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0f constant:-20.0f]; [self.view addConstraint:constraint];
但是,约束不适用于视图(至少不是我可以看到的)。相反,该视图似乎从屏幕上消失。然而,如果约束代码被注释掉,则视图再次加载适当的框架(显然没有使用约束)。当对Button或ImageView应用相同的约束时,约束将被完美地应用。这导致我认为问题是因为创建视图时的’initWithFrame’,因为按钮和ImageView实际上都不需要指定它的大小。
你怎么看?我该怎么做不同
解决方法
关于以编程方式停止GIF动画和以编程方式停止gif动画怎么办的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于android – 以编程方式调整布局(作为动画)、android – 如何以编程方式滚动动画、android – 如何通过USB编程方式停止手机充电、ios – 如何以编程方式将编程方式添加到以编程方式创建的UIView?等相关内容,可以在本站寻找。
本文标签: