在我的活动中,我有一个按钮,其中包含以下点击监听器:
final ImageButton startOverButton = (ImageButton) findViewById(R.id.start_over_button);
startOverButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(final View v) {
finish();//go back to the previous Activity
overridePendingTransition(R.anim.comming_in, R.anim.comming_out);
}
});
Run Code Online (Sandbox Code Playgroud)
它以我想要的方式动画返回上一个活动.但是,当用户按下Android默认后退按钮时,不会触发动画.我的问题是:我应该在哪里放置动画代码overridePendingTransition(R.anim.comming_in,R.anim.comming_out); 这样当用户点击我的按钮和默认的Android后退按钮时,这个动画都会被触发?
作为一个天真的尝试,我试图把overridePendingTransition(R.anim.comming_in,R.anim.comming_out); onDestroy()方法中的代码行但它不起作用.
先感谢您!
我正在尝试使用自定义过渡动画启动活动.到目前为止我发现的唯一方法是在上一个活动中不使用onPendingTransition())是在活动上使用自定义主题并定义activityOpenEnterAnimation,taskOpenEnterAnimation,windowEnterAnimation或windowAnimationStyle来设置动画.但是,这些属性都不适用于我.一些实验产生以下结果 -
如果我将windowAnimationStyle属性设置为某个自定义样式,该样式定义了activityOpenEnterAnimation,taskOpenEnterAnimation,windowEnterAnimation或windowAnimationStyle的值,我可以摆脱在活动开始时发生的默认过渡动画.它不会使用指定的实际值显示过渡动画,但至少不显示默认动画.
根据这里的参考文档,
我应该能够使用activityOpenEnterAnimation在活动开始时定义动画.但到目前为止没有成功.
有任何想法吗?
我在网上冲浪寻找一个很好的效果,在Android上翻页,似乎不是一个.由于我正在学习这个平台,能够做到这一点似乎是一件好事.
我设法在这里找到一个页面:http://wdnuon.blogspot.com/2010/05/implementing-ibooks-page-curling-using.html
- (void)deform
{
Vertex2f vi; // Current input vertex
Vertex3f v1; // First stage of the deformation
Vertex3f *vo; // Pointer to the finished vertex
CGFloat R, r, beta;
for (ushort ii = 0; ii < numVertices_; ii++)
{
// Get the current input vertex.
vi = inputMesh_[ii];
// Radius of the circle circumscribed by vertex (vi.x, vi.y) around A on the x-y plane
R = sqrt(vi.x * vi.x + pow(vi.y - A, 2));
// …
Run Code Online (Sandbox Code Playgroud) 如何在vue-router定义的页面(组件)之间实现淡入淡出效果页面转换?
从我现有的C#专业知识转移到在Objective C中为iPad/iPhone构建应用程序有多难?
我正在尝试在iOS中制作过渡动画,其中视图或视图控制器似乎会扩展以填充整个屏幕,然后在完成时缩回到其原来的位置.我不确定这种类型的过渡是否正式调用,但您可以在iPad的YouTube应用中看到一个示例.当您点击网格上的某个搜索结果缩略图时,它会从缩略图中展开,然后在您返回搜索时收缩回缩略图.
我对此有两个方面感兴趣:
在一个视图和另一个视图之间转换时,您将如何产生这种效果?换句话说,如果视图A占据屏幕的某个区域,您将如何将其转换为占据整个屏幕的视图B,反之亦然?
你会如何以这种方式过渡到模态视图?换句话说,如果UIViewController C当前正在显示并包含占据屏幕一部分的视图D,那么如何使它看起来像视图D变成UIViewController E,它在C上呈现模态?
编辑:我正在添加赏金,看看是否能让这个问题更加热爱.
编辑:我有一些源代码可以做到这一点,Anomie的想法就像一个魅力,有一些改进.我首先尝试动画模态控制器的视图(E),但它没有产生感觉像你正在放大屏幕的效果,因为它没有扩展(C)中缩略图视图周围的所有东西.因此,我尝试动画原始控制器的视图(C),但重绘它为一个生涩的动画,像背景纹理之类的东西没有正确缩放.所以我最后做的是拍摄原始视图控制器(C)的图像并在模态视图(E)内缩放.这种方法比我原来的方法复杂得多,但看起来确实不错!我认为iOS也必须如何进行内部转换.无论如何,这是我在UIViewController上作为类别编写的代码.
的UIViewController + Transitions.h:
#import <Foundation/Foundation.h>
@interface UIViewController (Transitions)
// make a transition that looks like a modal view
// is expanding from a subview
- (void)expandView:(UIView *)sourceView
toModalViewController:(UIViewController *)modalViewController;
// make a transition that looks like the current modal view
// is shrinking into a subview
- (void)dismissModalViewControllerToView:(UIView *)view;
@end
Run Code Online (Sandbox Code Playgroud)
的UIViewController + Transitions.m:
#import "UIViewController+Transitions.h"
@implementation UIViewController (Transitions)
// capture a screen-sized image of the receiver
- (UIImageView *)imageViewFromScreen { …
Run Code Online (Sandbox Code Playgroud) 我的ListView有一个简单的选择器
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/yellow_arc" android:state_activated="true"/>
<item android:drawable="@drawable/yellow_nonarc" android:state_activated="false"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
当视图的状态从激活变为未激活时,我希望为这些绘图之间的过渡设置动画,反之亦然.
如果您在API演示中运行示例,则会在视图的激活状态发生更改时看到明显的淡入/淡出动画.
所以我想要的是一个自定义动画,同时改变视图的状态.我认为它应该通过xml完成,但我找不到方法.
提前致谢.
编辑:
我想我找到了一些有用的东西activated_background.xml
,\Android\android-sdk\platforms\android-API_VERSION\data\res\drawable
其中包括
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:state_activated="true" android:drawable="@android:drawable/list_selector_background_selected" />
<item android:drawable="@color/transparent" />
</selector>
Run Code Online (Sandbox Code Playgroud)
因此API演示中的示例通过声明一个来实现这个淡出动画exitFadeDuration
.然而,这并不是我想要的.我想为状态drawables之间的过渡声明自定义动画,因为淡入/淡出动画对我的drawable来说看起来不太好.
我正在尝试使用nvd3.js创建一个实时图表,它会定期更新,并且会产生实时处理数据的印象.
现在我已经能够创建一个定期更新图形的函数,但我无法在"状态"之间进行平滑过渡,例如向左转换的行.
这是我使用nvd3.js所做的,这里有趣的代码是:
d3.select('#chart svg')
.datum(data)
.transition().duration(duration)
.call(chart);
Run Code Online (Sandbox Code Playgroud)
现在,我已经能够使用d3.js生成我想要的东西,但我希望能够使用nvd3.js提供的所有工具.这是我想用nvd3制作的
使用d3.js进行转换的有趣代码是:
function tick() {
// update the domains
now = new Date();
x.domain([now - (n - 2) * duration, now - duration]);
y.domain([0, d3.max(data)]);
// push the accumulated count onto the back, and reset the count
data.push(Math.random()*10);
count = 0;
// redraw the line
svg.select(".line")
.attr("d", line)
.attr("transform", null);
// slide the x-axis left
axis.transition()
.duration(duration)
.ease("linear")
.call(x.axis);
// slide the line left
path.transition()
.duration(duration)
.ease("linear")
.attr("transform", "translate(" …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将图像(加号)旋转45度以创建十字符号.到目前为止,我已经设法使用下面的代码来实现这一点,但它正在进行悬停,我想让它在点击时旋转.
使用CSS有一种简单的方法吗?
我的代码是:
CSS
img {
display: block;
margin: 20px;
}
.crossRotate {
-webkit-transition-duration: 1s;
-moz-transition-duration: 1s;
-o-transition-duration: 1s;
transition-duration: 1s;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
}
.crossRotate:hover {
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
Run Code Online (Sandbox Code Playgroud)
HTML
<body>
<img class="crossRotate" src="images/cross.png" alt="Cross Menu button" />
</body>
Run Code Online (Sandbox Code Playgroud)
这是jsfiddle演示.