Android window - view animation

瘦欲@ 提交于 2019-12-25 01:47:22

问题


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();

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.


回答1:


Please try changing your code to the following:

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

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

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
});

You can find the animations for the Android platform here.



来源:https://stackoverflow.com/questions/18978233/android-window-view-animation

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