Android网络应用开发中有遇到,业务接口后期调用时数据要加密传输,由于先前没在启动时升级检查,导致原来版本无法升级(只在登录后可升级),好在处于内部测试阶段。让Android网络应用启动时升级检查就可以避免上述情况发生,要点:
1,继承TranslateAnimation或RotateAnimation,在applyTransformation中刷新动画parentView的界面。如:
private final class MyTranslateAnimation extends TranslateAnimation {
private View backgroundView;
public MyTranslateAnimation(View backgroundView, int fromXType, float fromXValue, int toXType, float toXValue,
int fromYType, float fromYValue, int toYType, float toYValue) {
super(fromXType, fromXValue, toXType, toXValue, fromYType, fromYValue, toYType, toYValue);
this.backgroundView = backgroundView;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
backgroundView.postInvalidate();
}
}
2,调用:
TranslateAnimation cardAnimation = new MyTranslateAnimation(backgroundView, Animation.RELATIVE_TO_PARENT, 0.01f,
Animation.RELATIVE_TO_PARENT, 0.35f, Animation.RELATIVE_TO_PARENT, 0.1f, Animation.RELATIVE_TO_PARENT,
0.1f);
cardAnimation.setDuration(2000);
cardAnimation.setRepeatCount(Animation.INFINITE);
cardAnimation.setRepeatMode(Animation.REVERSE);
imageView.setAnimation(cardAnimation);
利用AnimationDrawable实现类似gif效果的动画:
final AnimationDrawable drawable = new AnimationDrawable();
drawable.addFrame(activity.getResources().getDrawable(R.drawable.kaiguan), 750);//添加图片帧到AnimationDrawable
drawable.addFrame(activity.getResources().getDrawable(R.drawable.kaiguan2), 1250);
drawable.setOneShot(false);//设置为循环播放
ImageView imageView = (ImageView)findViewById(R.id.imageView);
imageView.setImageDrawable(drawable);//AnimationDrawable对象给imageView
drawable.start();//动画播放
drawable.stop();//动画停止
摘自某文摘一段话:
在onActivityResult中,即便是从后一个页面按back键返回的也是有resultCode的,且其值为0,其data为null.
1.对一般布局如(LinearLayout)设置selector后,点击没有选中的效果,可设置其android:clickable="true" 即可。
public LayerDrawable test(Context context, dynamicImg) {
LayerDrawable layerDrawable =(LayerDrawable) context.getResources().getDrawable(R.drawable.layerlist);
Drawable drawable = context.getResources().getDrawable(R.drawable.ic_launcher);
layerDrawable.setDrawableByLayerId(R.id.userimage, dynamicImg);
return layerDrawable;
}
<% highlight html %>
<a href="/categories.html#reading">
reading
</a>
<sup>[8]</sup>
,
<a href="/categories.html#linux">
linux
</a>
<sup>[7]</sup>
,
<a href="/categories.html#embedded">
embedded
</a>
<sup>[1]</sup>
,
<a href="/categories.html#android">
android
</a>
<sup>[35]</sup>
,
<a href="/categories.html#web">
web
</a>
<sup>[3]</sup>
,
<a href="/categories.html#network">
<b>network</b>
</a>
<sup>[7]</sup>
,
<a href="/categories.html#cocos2d">
cocos2d
</a>
<sup>[5]</sup>
,
<a href="/categories.html#java">
java
</a>
<sup>[2]</sup>
,
<a href="/categories.html#git">
git
</a>
<sup>[1]</sup>
,
<a href="/categories.html#intellij idea">
intellij idea
</a>
<sup>[1]</sup>
,