Android 窗口 - 查看动画 [英] Android window - view animation

查看:58
本文介绍了Android 窗口 - 查看动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是钛工作室的新手,我现在正在阅读文档 2 天,并尝试制作简单的幻灯片动画,甚至除了打开模态窗口之外的任何类型的任何动画.但我无法让它工作.这是我现在尝试但失败的方法:

Hello I'm new to titanium studio I'm reading the docs 2 days now and trying to make a simple slide animation or even any animation of any kind except opening a modal window. but I can't make it work.Here is what I was trying now but fails:

var slide_it_left = Titanium.UI.createAnimation();
    slide_it_left.left = 500; 
    slide_it_left.duration = 500;

var mainWinOpts = {
    backgroundColor:'#fff',
    fullscreen:true,
    navBarHidden: true
}

var animWinOpts = {
    navBarHidden: true,
    backgroundColor:'#000',
    top:0,
    left:0,
    width: Ti.Platform.displayCaps.platformWidth,
    height: Ti.Platform.displayCaps.platformHeight,
    fullscreen:false,
    animated:true       
}

var mainWin = Ti.UI.createWindow(mainWinOpts);
var animWin = Ti.UI.createWindow(animWinOpts); 

var labelOpts = {
    text: 'click me!',
    textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
    font: {
        fontFamily: 'monospace',
        fontSize: 24
    },
    borderWidth: 1,
    color: '#2e2e2e',
    borderColor: '#2e2e2e',
    backgroundColor: '#dedede',
    top: 50,
    left: 50,
    width: Ti.Platform.displayCaps.platformWidth,
    height: Ti.Platform.displayCaps.platformHeight,
    opacity: 1.00,
    width: Ti.UI.SIZE, 
    height: Ti.UI.SIZE
};

var label = Ti.UI.createLabel(labelOpts);

label.addEventListener('click',function(){
    animWin.open(slide_it_left);
})

mainWin.add(label);
mainWin.open();

这是我从他们的文档中尝试过的其他片段 - 论坛不起作用.有人可以为我提供一些适用于 android 窗口或视图动画的工作示例或参考.或者指出我做错了什么.提前致谢.

This among other snippets I tried from their docs - forums isn't working. Could someone please provide me some working samples or references for android window or view animation. Or point out what I'm doing wrong. Thank you in advance.

推荐答案

请尝试将您的代码更改为以下内容:

Please try changing your code to the following:

label.addEventListener('click',function(){
    animWin.open();
    animWin.animate(slide_it_left);
});

您不能使用动画对象作为 open() 的参数.在此处查看有效参数.

You cannot use the animation object as a parameter for open(). Have a look at the valid params here.

此外,文档给出了在 Android 上的窗口中滑动的示例,这很可能是您想要实现的:

Moreover, the docs give an example for sliding in a window on Android, which is very likely what you are trying to achieve:

var win2 = Ti.UI.createWindow({fullscreen:false});
win2.open({
    activityEnterAnimation: Ti.Android.R.anim.slide_in_left,
    activityExitAnimation: Ti.Android.R.anim.slide_out_right
});

您可以在此处找到适用于 Android 平台的动画.

You can find the animations for the Android platform here.

这篇关于Android 窗口 - 查看动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆