下面列出了android.widget.ImageView#startAnimation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void initView() {
scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
scanLine = (ImageView) findViewById(R.id.capture_scan_line);
findViewById(R.id.capture_imageview_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
isHasSurface = false;
beepManager = new BeepManager(this);
TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
0.9f);
animation.setDuration(3000);
animation.setRepeatCount(-1);
animation.setRepeatMode(Animation.RESTART);
scanLine.startAnimation(animation);
}
/**
* Start all the animations
*/
private void startAnimation() {
ImageView centerWheel = (ImageView)findViewById(org.developfreedom.logmein.R.id.center_wheel);
View infoView = findViewById(org.developfreedom.logmein.R.id.info);
Animation rotation = AnimationUtils.loadAnimation(this, org.developfreedom.logmein.R.anim.rotation_start);
centerWheel.startAnimation(rotation);
Animation slideLeft = AnimationUtils.loadAnimation(this, org.developfreedom.logmein.R.anim.slide_in_left);
mButtonLogout.startAnimation(slideLeft);
Animation slideRight = AnimationUtils.loadAnimation(this, org.developfreedom.logmein.R.anim.slide_in_right);
mButtonWeb.startAnimation(slideRight);
Animation slideTop = AnimationUtils.loadAnimation(this, org.developfreedom.logmein.R.anim.slide_in_top);
infoView.startAnimation(slideTop);
mButtonLogin.startAnimation(slideTop);
Animation slideBottom = AnimationUtils.loadAnimation(this, org.developfreedom.logmein.R.anim.slide_in_bottom);
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_capture);
scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
scanLine = (ImageView) findViewById(R.id.capture_scan_line);
inactivityTimer = new InactivityTimer(this);
beepManager = new BeepManager(this);
TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
0.9f);
animation.setDuration(4500);
animation.setRepeatCount(-1);
animation.setRepeatMode(Animation.RESTART);
scanLine.startAnimation(animation);
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_capture);
scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
scanLine = (ImageView) findViewById(R.id.capture_scan_line);
inactivityTimer = new InactivityTimer(this);
TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
0.9f);
animation.setDuration(4500);
animation.setRepeatCount(-1);
animation.setRepeatMode(Animation.RESTART);
scanLine.startAnimation(animation);
initButton();
}
/**
* 1
*/
@Override
protected void initView() {
setContentView(R.layout.activity_antivirus);
// bind view
ivScan = (ImageView) findViewById(R.id.iv_scan);
tvUseTime = (TextView) findViewById(R.id.tv_use_time);
llLog = (LinearLayout) findViewById(R.id.ll_log);
pbProgress = (ProgressBar) findViewById(R.id.pb_progress);
// start a rotate animation
Animation rotateAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate_forever);
rotateAnimation.setDuration(2000);
ivScan.startAnimation(rotateAnimation);
}
public static void showProgressDialog(Context context, String text) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.ct_progressdialog, null);
TextView content = (TextView) v.findViewById(R.id.dialog_content);
content.setText(text);
ImageView spaceshipImage = (ImageView) v.findViewById(R.id.dialog_img);
// 加载动画
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(context,
R.anim.progress_anim);
// 使用ImageView显示动画
spaceshipImage.startAnimation(hyperspaceJumpAnimation);
dialog = new Dialog(context, R.style.CustomDialog);
dialog.setCanceledOnTouchOutside(false); //触摸外面不消失
dialog.setContentView(v, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
dialog.getWindow().setWindowAnimations(R.style.dialogAnim);
dialog.show();
/*//设置progressdilog的高度和宽度
int sreenWidth = DensityUtil.getWidthInPx(context);
dialog.getWindow().setLayout(sreenWidth - 64, DensityUtil.dip2px(context, 48));*/
}
public static void rotateImageForever(Context context, ImageView ivSwap, int id) {
Animation operatingAnim = AnimationUtils.loadAnimation(context,id);
LinearInterpolator lin = new LinearInterpolator();
operatingAnim.setInterpolator(lin);
if (operatingAnim != null) {
ivSwap.startAnimation(operatingAnim);
}
}
public void handleMessage(Message msg) {
if (msg.what == MSG_TYPE_DISPLAY_IMAGE) {
Holder holder = (Holder) msg.obj;
ImageView imageView = (ImageView) mListView.findViewWithTag(holder.url);
if (imageView != null && holder.bitmap != null) {
imageView.setImageBitmap(holder.bitmap);
Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.alpha_action_long);
imageView.startAnimation(anim);
}
}
}
/**
* Function to init compass activity
*/
private void init() {
countryName = (TextView) findViewById(R.id.textView11);
if (MainActivity.locationInfo != null)
countryName.setText(getResources().getConfiguration()
.locale.getDisplayLanguage().equals("العربية")
? ConfigPreferences.getLocationConfig(this).name_english
: ConfigPreferences.getLocationConfig(this).name);
//init compass activity views
Quibladegree = (TextView) findViewById(R.id.textView12);
Quibladegree.setText(getString(R.string.qibla_direction) + " " + ConfigPreferences.getQuibla(this));
indicator = (ImageView) findViewById(R.id.imageView2);
compass = (RelativeLayout) findViewById(R.id.compassContainer);
compassMapContainer = (RelativeLayout) findViewById(R.id.compassMapContainer);
compassMain = (RelativeLayout) findViewById(R.id.compassMain);
smallCircleLevel = (ImageView) findViewById(R.id.smallCircle);
innerPosition = (RelativeLayout) findViewById(R.id.innerplace);
pointerIndicatorInner = (ImageView) findViewById(R.id.poinerInner);
redCircle = (ImageView) findViewById(R.id.red_circle);
errorImage = (ImageView) findViewById(R.id.error);
//init sensor services
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
compassLevel = (ImageView) findViewById(R.id.compassLevel);
//animate compass pointer
RotateAnimation ra = new RotateAnimation(currentDegree, MainActivity.quiblaDegree,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
ra.setDuration(400);
ra.setFillAfter(true);
indicator.startAnimation(ra);
pointerIndicatorInner.startAnimation(ra);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.an_scale);
ImageView imgv = (ImageView) findViewById(R.id.img);
Animation alphaAnimation = AnimationUtils.loadAnimation(this, R.anim.scale);
imgv.startAnimation(alphaAnimation);
Intent intent = new Intent();
intent.putExtra("rs", "success");
setResult(2, intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.an_translate);
imgv0 = (ImageView) findViewById(R.id.img0);
alphaAnimation0 = AnimationUtils.loadAnimation(this, R.anim.translate0);
imgv0.startAnimation(alphaAnimation0);
imgv1 = (ImageView) findViewById(R.id.img1);
alphaAnimation1 = AnimationUtils.loadAnimation(this, R.anim.translate1);
imgv1.startAnimation(alphaAnimation1);
imgv2 = (ImageView) findViewById(R.id.img2);
alphaAnimation2 = AnimationUtils.loadAnimation(this, R.anim.translate2);
imgv2.startAnimation(alphaAnimation2);
imgv3 = (ImageView) findViewById(R.id.img3);
alphaAnimation3 = AnimationUtils.loadAnimation(this, R.anim.translate3);
imgv3.startAnimation(alphaAnimation3);
imgv4 = (ImageView) findViewById(R.id.img4);
alphaAnimation4 = AnimationUtils.loadAnimation(this, R.anim.translate4);
imgv4.startAnimation(alphaAnimation4);
imgv5 = (ImageView) findViewById(R.id.img5);
alphaAnimation5 = AnimationUtils.loadAnimation(this, R.anim.translate5);
imgv5.startAnimation(alphaAnimation5);
}
private void initview() {
final ViewGroup previewGroup = (ViewGroup) findViewById(R.id.preview);
imageView = new ImageView(this);
imageView.setVisibility(View.GONE);
previewGroup.addView(scene, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
previewGroup.addView(imageView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
btn_record = (Button) findViewById(R.id.ar_record);
btn_record.setOnClickListener(this);
center = (ImageButton) findViewById(R.id.center);
center.setOnClickListener(this);
ivAnim = (ImageView) findViewById(R.id.iv_anim);
rlAnim = (RelativeLayout) findViewById(R.id.rl_anim);
tvLoading = (TextView) findViewById(R.id.tv_loading);
Animation animation = AnimationUtils.loadAnimation(ArRecordActivity.this, R.anim.anim);
animation.setInterpolator(new LinearInterpolator());
ivAnim.startAnimation(animation);
progressText = (TextView) findViewById(R.id.progress_text);
loadScene("scene.js");
if(TextUtils.isEmpty(appKey)&&TextUtils.isEmpty(appSecret)&&TextUtils.isEmpty(arid)){
Toast.makeText(this, "数据KEY为空,无法加载", Toast.LENGTH_SHORT).show();
}else{
loadARID(arid);
}
}
/**
* 将图片旋转一圈
* @param context
* @param ivSwap
*/
public static void rotateImageOnce(Context context, ImageView ivSwap) {
Animation operatingAnim = AnimationUtils.loadAnimation(context,
R.anim.image_rotate_once);
LinearInterpolator lin = new LinearInterpolator();
operatingAnim.setInterpolator(lin);
if (operatingAnim != null) {
ivSwap.startAnimation(operatingAnim);
}
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void addAnimationToMenuItem(MenuItem menuItem, @LayoutRes int layoutResource,
@AnimRes int animationId) {
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ImageView iv = (ImageView)inflater.inflate(layoutResource, null);
Animation animation = AnimationUtils.loadAnimation(this, animationId);
iv.startAnimation(animation);
menuItem.setActionView(iv);
}
/**
* Applies the animation to the image view present in OTT.
* @param animation
*/
public void applyAnimation(Animation animation) {
if(mCreatedOttLayer != null) {
ImageView drawnImageView = (ImageView) mCreatedOttLayer.getChildAt(0);
drawnImageView.startAnimation(animation);
}
}
private void rotateReceiveButton() {
ImageView rcvBtn = (ImageView) getActivity().findViewById(R.id.receivebtn);
final Animation rotAnim = AnimationUtils.loadAnimation(getContext(), R.anim.rotate360);
rcvBtn.startAnimation(rotAnim);
}
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_UPDATE_LOADING:
if (isFirstRun()) {
progressDialog = ProgressDialog.show(
Main.this,
getString(R.string.app_name), getString(R.string.loading), false, false);
}
Animation rotation = AnimationUtils.loadAnimation(context, R.anim.refresh_rotate);
RelativeLayout layout = new RelativeLayout(context);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
ImageView imageView = new ImageView(context);
imageView.setLayoutParams(params);
layout.setGravity(Gravity.CENTER_VERTICAL | Gravity.TOP);
layout.addView(imageView);
imageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_refersh));
imageView.startAnimation(rotation);
if (mMenuRefersh != null) {
mMenuRefersh.setActionView(layout);
}
break;
case MESSAGE_UPDATE_COMPLETE:
try {
Fragment fragment = mScrollTabsFragment.getCurrentFragment();
if (fragment instanceof QuestionsListFragment) {
((QuestionsListFragment) fragment).updateQuestionsFromDatabase();
}
} catch (NullPointerException e) {
e.printStackTrace();
} finally {
mScrollTabsFragment.notifyDatasetChanged();
}
if (mMenuRefersh != null) {
View v = mMenuRefersh.getActionView();
if (v != null) {
v.clearAnimation();
}
mMenuRefersh.setActionView(null);
}
if (progressDialog != null) {
progressDialog.dismiss();
}
if (mFetchQuestionsTask.hasError()) {
Helper.showShortToast(context, mFetchQuestionsTask.getErrorMessage());
}
break;
case MESSAGE_UPDATE_SHOW_RESULT:
if (mFetchQuestionsTask != null) {
String message = getString(R.string.no_newer_questions);
if (mFetchQuestionsTask.getAffectedRows() > 0) {
message = String.format(getString(R.string.affectRows), mFetchQuestionsTask.getAffectedRows());
}
Helper.showShortToast(context, message);
}
break;
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/**
* 设置为竖屏
*/
if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_gos_capture);
scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
scanLine = (ImageView) findViewById(R.id.capture_scan_line);
inactivityTimer = new InactivityTimer(this);
TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT,
0.0f);
animation.setDuration(4500);
animation.setRepeatCount(-1);
animation.setRepeatMode(Animation.RESTART);
scanLine.startAnimation(animation);
btnCancel = (Button) findViewById(R.id.btn_cancel);
ivReturn = (ImageView) findViewById(R.id.iv_return);
OnClickListener myClick = new OnClickListener() {
@Override
public void onClick(View arg0) {
CaptureActivity.this.finish();
}
};
btnCancel.setOnClickListener(myClick);
ivReturn.setOnClickListener(myClick);
}
private void setupIconAnim() {
ImageView icon = getView().findViewById(R.id.about_icon);
Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.icon_anim);
icon.startAnimation(animation);
}
public void clockwise(View view) {
ImageView image = (ImageView) findViewById(R.id.dualSIMimageView);
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.clockwise);
image.startAnimation(animation);
readSims();
}