Android scale view

◇◆丶佛笑我妖孽 提交于 2019-12-06 16:29:40

I've solved the problem by creating animation xml file with duration=0, which sets desired parameters. It is also possible to create such animation via code. Then to apply it, just use:

Animation animationInit = AnimationUtils.loadAnimation(context, R.anim.gallery_init);
v.startAnimation(animationInit);
ahodder

This will allow you to use straight up float values (percent) when handeling drawing and placements. Refer to: this lovely site which really helps with views.

public class MyView extends View {


    ...


    @Override public void onDraw(Canvas canvas) {
        canvas.save(Canvas.MATRIX_SAVE_FLAG);
        canvas.scale((getWidth() > getHeight()) ? getHeight() : getWidth());

        // Your other code

        canvas.restore();
    }

    ...

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!