当前位置: 首页>>代码示例>>Java>>正文


Java AnimationDrawable.setOneShot方法代码示例

本文整理汇总了Java中android.graphics.drawable.AnimationDrawable.setOneShot方法的典型用法代码示例。如果您正苦于以下问题:Java AnimationDrawable.setOneShot方法的具体用法?Java AnimationDrawable.setOneShot怎么用?Java AnimationDrawable.setOneShot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.drawable.AnimationDrawable的用法示例。


在下文中一共展示了AnimationDrawable.setOneShot方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTitle(title);
    infoText = (TextView) findViewById(R.id.infoView);
    imgView = (ImageView) findViewById(R.id.cardbg);
    imgView.setBackgroundResource(R.drawable.myanim);
    _animation = (AnimationDrawable) imgView.getBackground();
    _animation.setOneShot(false);
    uiHandler = new MyHandler(this);

    mBluetoothReader = new BluetoothReader();
    mBluetoothReader.setOnReaderStateListener(new BluetoothReader.OnReaderStateListener() {
        @Override
        public void onReaderStateChange(String readerName, int readerState) {
            if (readerName.isEmpty() == false) {
                uiHandler.obtainMessage(READER_MESSAGE, readerState, -1, readerName).sendToTarget();
            }
        }
    });

    View scan = findViewById(R.id.btScan);
    scan.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            infoText.setText("Select bluetooth reader for connect...");
            Intent serverIntent = new Intent(TestActivity3.this, DeviceListActivity.class);
            startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
        }
    });
}
 
开发者ID:NaOHAndroid,项目名称:Logistics-guard,代码行数:33,代码来源:TestActivity3.java

示例2: recreateWithParams

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
public void recreateWithParams(Context context, @ColorInt int spinnerColor, int duration, boolean clockwise) {
    boolean wasRunning = false;
    boolean oneShot = isOneShot();

    if (((AnimationDrawable)this.getBackground()).isRunning()) {
        wasRunning = true;
        stop();
    }

    AnimationDrawable newSpinner = createSpinner(context, spinnerColor, duration, clockwise);
    if (newSpinner != null) {
        if (oneShot) newSpinner.setOneShot(true);
        this.spinnerColor = spinnerColor;
        this.duration = duration;
        this.clockwise = clockwise;
        updateSpinner(newSpinner);
    }

    if (wasRunning) start();
}
 
开发者ID:Samehadar,项目名称:IOSDialog,代码行数:21,代码来源:CamomileSpinner.java

示例3: tileifyIndeterminate

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
/**
 * Convert a AnimationDrawable for use as a barberpole animation.
 * Each frame of the animation is wrapped in a ClipDrawable and
 * given a tiling BitmapShader.
 */
private Drawable tileifyIndeterminate(Drawable drawable) {
    if (drawable instanceof AnimationDrawable) {
        AnimationDrawable background = (AnimationDrawable) drawable;
        final int N = background.getNumberOfFrames();
        AnimationDrawable newBg = new AnimationDrawable();
        newBg.setOneShot(background.isOneShot());

        for (int i = 0; i < N; i++) {
            Drawable frame = tileify(background.getFrame(i), true);
            frame.setLevel(10000);
            newBg.addFrame(frame, background.getDuration(i));
        }
        newBg.setLevel(10000);
        drawable = newBg;
    }
    return drawable;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:23,代码来源:IcsProgressBar.java

示例4: HitalkRotationHeader

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
public HitalkRotationHeader(Context context,int[] pullAnimSrcs,int[] refreshAnimSrcs){
    this.context = context;
    if (pullAnimSrcs!=null) this.pullAnimSrcs = pullAnimSrcs;
    if (refreshAnimSrcs!=null) this.refreshAnimSrcs = refreshAnimSrcs;
    animationPull = new AnimationDrawable();
    animationPullFan = new AnimationDrawable();
    animationRefresh = new AnimationDrawable();
    for (int i=1;i< this.pullAnimSrcs.length;i++) {
        animationPull.addFrame(ContextCompat.getDrawable(context, this.pullAnimSrcs[i]),100);
        animationRefresh.setOneShot(true);
    }
    for (int i= this.pullAnimSrcs.length-1;i>=0;i--){
        animationPullFan.addFrame(ContextCompat.getDrawable(context, this.pullAnimSrcs[i]), 100);
        animationRefresh.setOneShot(true);
    }
    for (int src: this.refreshAnimSrcs) {
        animationRefresh.addFrame(ContextCompat.getDrawable(context, src),150);
        animationRefresh.setOneShot(false);
    }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:21,代码来源:HitalkRotationHeader.java

示例5: initAnim

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
private void initAnim() {

        animationDrawable = new AnimationDrawable();
        animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode1), 100);
        animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode2), 100);
        animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode3), 100);
        animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode4), 100);
        animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode5), 100);
        animationDrawable.setOneShot(true);
        animationDrawable.setExitFadeDuration(300);
        animationDrawable.setEnterFadeDuration(100);

        ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(null, "scaleX", 1.f, 0.f);
        ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(null, "scaleY", 1.f, 0.f);
        animatorSet = new AnimatorSet();
        animatorSet.setDuration(300l);
        animatorSet.playTogether(objectAnimator1, objectAnimator2);

        objectAnimator = ObjectAnimator.ofFloat(null, "alpha", 1.f, 0.f);
        objectAnimator.setDuration(2000l);
    }
 
开发者ID:javonleee,项目名称:DragPointView,代码行数:22,代码来源:SampleActivity.java

示例6: onCreate

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_keyframe_animation);

    ImageView imageview = (ImageView) findViewById(R.id.imageview);

    // Create the AnimationDrawable in which we will store all frames of the animation
    final AnimationDrawable animationDrawable = new AnimationDrawable();
    for (int i = 0; i < 10; ++i) {
        animationDrawable.addFrame(getDrawableForFrameNumber(i), 300);
    }
    // Run until we say stop
    animationDrawable.setOneShot(false);

    imageview.setImageDrawable(animationDrawable);

    // When the user clicks on the image, toggle the animation on/off
    imageview.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (animationDrawable.isRunning()) {
                animationDrawable.stop();
            } else {
                animationDrawable.start();
            }
        }
    });
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:31,代码来源:KeyframeAnimation.java

示例7: createAnimationDrawable

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
public static AnimationDrawable createAnimationDrawable(Context context, File directory, FilenameFilter filter, int width, int height) throws IllegalArgumentException {
    List<AnimationFrame> animationFrameList = createAnimationDrawableList(context, directory, filter, width, height);

    AnimationDrawable animation = new AnimationDrawable();

    for (AnimationFrame frame : animationFrameList) {
        animation.addFrame(frame.getDrawable(), frame.getDuration());
    }

    animationFrameList.clear();
    animationFrameList = null;

    animation.selectDrawable(0);
    animation.setOneShot(false);

    return animation;
}
 
开发者ID:yongbeam,项目名称:AirQuickUtils,代码行数:18,代码来源:AirAnimation.java

示例8: startAnimationImages

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
/**
 * 开始帧动画(目前只支持本地动画)
 *
 * @param images
 * @param duration
 * @return
 */
public UDImageView startAnimationImages(String[] images, int duration, boolean repeat) {
    final T view = getView();
    if (view != null) {
        Drawable[] frames = null;
        if (images != null && images.length > 0) {
            if (getLuaResourceFinder() != null) {
                frames = new Drawable[images.length];
                for (int i = 0; i < images.length; i++) {
                    frames[i] = getLuaResourceFinder().findDrawable(images[i]);
                }
            }
            if (frames != null && frames.length > 0) {
                mFrameAnimation = new AnimationDrawable();
                try {
                    for (Drawable frame : frames) {
                        mFrameAnimation.addFrame(frame, duration);
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                    LogUtil.e("[LuaView-Error] UDImageView.startAnimationImages failed!");
                }
                mFrameAnimation.setOneShot(!repeat);
                LuaViewUtil.setBackground(view, mFrameAnimation);
                mFrameAnimation.setVisible(true, true);
                mFrameAnimation.start();
            }
        }
    }
    return this;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:38,代码来源:UDImageView.java

示例9: getAnimationDrawable

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
/**
 * 逐帧动画
 *
 * @param images   imagePath的list
 * @param duration 每张显示时长
 * @return 动画对象
 */
public static AnimationDrawable getAnimationDrawable(List<String> images, int duration) {
    AnimationDrawable animationDrawable = new AnimationDrawable();
    for (String imagepath : images) {
        Bitmap bitmap = BitmapFactory.decodeFile(imagepath);
        Drawable drawable = new BitmapDrawable(bitmap);
        animationDrawable.addFrame(drawable, duration);
    }
    animationDrawable.setOneShot(false);
    return animationDrawable;

}
 
开发者ID:zhonglikui,项目名称:cardinalsSample,代码行数:19,代码来源:AnimationUtils.java

示例10: ItemConversationAdapter

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
public ItemConversationAdapter(Context context, List<ConversationEntity> objects) {
    this.context = context;
    this.layoutInflater = LayoutInflater.from(context);
    this.objects = objects;

    animationDrawable = new AnimationDrawable();
    animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode1), 100);
    animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode2), 100);
    animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode3), 100);
    animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode4), 100);
    animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode5), 100);
    animationDrawable.setOneShot(true);
    animationDrawable.setExitFadeDuration(300);
    animationDrawable.setEnterFadeDuration(100);
}
 
开发者ID:javonleee,项目名称:DragPointView,代码行数:16,代码来源:ItemConversationAdapter.java

示例11: addExplodeImageView

import android.graphics.drawable.AnimationDrawable; //导入方法依赖的package包/类
/**
 * 消失后的动画
 *
 * @param x        BadgeView消失的x坐标
 * @param y        BadgeView消失的y坐标
 * @param rootView DecorView
 */
private void addExplodeImageView(final float x, final float y, final ViewGroup rootView) {
    final int totalDuration = 500;//动画总时长
    int d = totalDuration / 5;//每帧时长

    final ImageView explodeImage = new ImageView(getContext());
    final AnimationDrawable explodeAnimation = new AnimationDrawable();//创建帧动画
    //添加帧,图片放置在drawable-nodpi下
    explodeAnimation.addFrame(ContextCompat.getDrawable(getContext(), R.drawable.pop1), d);
    explodeAnimation.addFrame(ContextCompat.getDrawable(getContext(), R.drawable.pop2), d);
    explodeAnimation.addFrame(ContextCompat.getDrawable(getContext(), R.drawable.pop3), d);
    explodeAnimation.addFrame(ContextCompat.getDrawable(getContext(), R.drawable.pop4), d);
    explodeAnimation.addFrame(ContextCompat.getDrawable(getContext(), R.drawable.pop5), d);
    //设置动画只播放一次
    explodeAnimation.setOneShot(true);

    explodeImage.setImageDrawable(explodeAnimation);
    explodeImage.setVisibility(INVISIBLE);

    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    rootView.addView(explodeImage, params);

    explodeImage.post(new Runnable() {
        @Override
        public void run() {
            explodeImage.setX(x - explodeImage.getWidth() / 2);
            explodeImage.setY(y - explodeImage.getHeight() / 2);
            explodeImage.setVisibility(VISIBLE);

            explodeAnimation.start();

            Handler handler = explodeImage.getHandler();
            if (handler != null) {
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        explodeImage.setVisibility(GONE);
                        //动画结束后DecorView中移除ImageView控件
                        rootView.removeView(explodeImage);
                        DragBadgeView.this.setVisibility(INVISIBLE);
                    }
                }, totalDuration);
            }
        }
    });
}
 
开发者ID:fendoudebb,项目名称:DragBadgeView,代码行数:55,代码来源:DragBadgeView.java


注:本文中的android.graphics.drawable.AnimationDrawable.setOneShot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。