我正在制作幻灯片,我遇到了一些麻烦.
我在xml中创建了2个动画,用于淡入和淡出:
fadein.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="2000"/>
</set>
Run Code Online (Sandbox Code Playgroud)
fadeout.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="2000"/>
</set>
Run Code Online (Sandbox Code Playgroud)
我正在做的是使用淡入淡出效果从ImageView更改图像,因此当前显示的图像将淡出,另一个将淡入.考虑到我已经设置了图像,我可以淡出此图像而不用问题,这个:
Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.your_fade_in_anim);
imageView.startAnimation(fadeoutAnim);
Run Code Online (Sandbox Code Playgroud)
但是,我设置下一个要显示的图像:
imageView.setImageBitmap(secondImage);
Run Code Online (Sandbox Code Playgroud)
它只是出现在imageView中,当我设置动画时它会隐藏图像,淡入它...有没有办法解决它,我的意思是,当我做imageView.setImageBitmap(secondImage); 命令,图像不会立即显示,只有当淡入动画执行时?
当您单击一个复选框时,我希望消息缓慢淡入.
为什么.fadeIn()在这个例子中不起作用?
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>Text XHTML Page</title>
<link href="css/main.css" rel="stylesheet" type="text/css" media="all"/>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="javascript/main.js"></script>
</head>
<body>
<div class="checkboxList">
<div class="title">Languages:</div>
<div class="row"><input class="checkbox" type="checkbox"/><span class="label">Ruby</span></div>
<div class="row"><input type="checkbox"/><span class="label">PHP</span></div>
<div class="row"><input type="checkbox"/><span class="label">C#</span></div>
<div class="row"><input type="checkbox"/><span class="label">Python</span></div>
<div class="row"><input type="checkbox"/><span class="label">JavaScript</span></div>
</div>
<p id="message"></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
google.load("jquery", "1.3.2");
//run when page is loaded
google.setOnLoadCallback(function() {
$('.checkboxList .row').css('color','red');
$('.checkboxList input').attr('checked', true);
$('.checkboxList input').bind('click', …
Run Code Online (Sandbox Code Playgroud) 我有一堆缩略图,我正在加载一种风格,visibility: hidden;
以便他们都保持正确的布局.一旦页面完全加载,我就有了一个淡入淡出的jquery函数.当它们的样式被设置为时,这很有用,display: none;
但显然布局搞砸了.有什么建议?
继承人的淡出线:
$('.littleme').fadeIn('slow');
Run Code Online (Sandbox Code Playgroud) 使用jQuery我正在创建一个基本的"工具提示"动画,以便工具提示将出现在一个小动画中,在该动画中它会淡入视图并垂直移动.
到目前为止我有这个:
$('.tooltip').fadeIn('slow');
$('.tooltip').animate({ top: "-10px" }, 'slow');
Run Code Online (Sandbox Code Playgroud)
这样做或这样做:
$('.tooltip').fadeIn('slow').animate({ top: "-10px" }, 'slow');
Run Code Online (Sandbox Code Playgroud)
动画将一次运行一个,首先是淡入淡出,然后是垂直动画.有没有办法让它同时做到这两件事?
我已经在这几天苦苦挣扎,最后才决定问.这很简单,我必须遗漏一些非常基本的东西.
我有一个XML布局页面,其中定义了图像.我有两个动画XML页面,一个用于将alpha从0更改为1,另一个用于从1更改为0以创建"闪烁"效果.所以alphaAnimation是用XML定义的,我只需要调用它.
图像弹出,但没有循环闪烁效果.
public class blinker extends Activity {
//create name of animation
Animation myFadeInAnimation;
Animation myFadeOutAnimation;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scanning_view);
//grab the imageview and load the animations
ImageView myImageView = (ImageView) findViewById(R.id.blinkingView01);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(null, R.anim.fade_in);
Animation myFadeOutAnimation = AnimationUtils.loadAnimation(null, R.anim.fade_out);
//fade it in, and fade it out.
myImageView.startAnimation(myFadeInAnimation);
myImageView.startAnimation(myFadeOutAnimation);
}
}
Run Code Online (Sandbox Code Playgroud)
Anim资源中的两个XML动画布局:
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="50" android:repeatCount="infinite"/>
</set> …
Run Code Online (Sandbox Code Playgroud) 通过使用以下css将其类更改为.elementToFadeInAndOut,我可以创建一个不透明度为零的元素:
.elementToFadeInAndOut {
opacity: 1;
transition: opacity 2s linear;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法通过编辑同一个类的css,使元素淡入后淡出?
非常感谢您的宝贵时间.
我想在Android活动屏幕上显示一张照片,从苍白单调的棕褐色到最终的全彩色逐渐淡入淡出.我知道如何在Graphic对象的Java Image/BufferedImage上进行操作,但遗憾的是我对Android编程环境一无所知.有人可以帮忙吗?
我想做一个非常简单的alpha动画,但我找不到有效的方法.
我们的想法是在视图上执行此动画:
我试图用AnimationSet实现它:
AnimationSet animationSet = new AnimationSet(true);
Animation animation1 = new AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
animation1.setDuration(1000);
Animation animation2 = new AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
animation2.setDuration(1000);
animation2.setStartOffset(5000);
Animation animation3 = new AlphaAnimation(0.0f, 0.0f);
animation3.setDuration(4000)
animation3.setStartOffset(6000);
animationSet.add(animation1);
animationSet.add(animation2);
animationSet.add(animation3);
Run Code Online (Sandbox Code Playgroud)
等等..
但它接下来第三个动画与所有的alpha动画混乱,我认为这导致Android管理这种类型的动画的方式内部不连贯.
任何的想法?
谢谢.
我从这里得到了FragmentBasics示例.当我滑动而不是左右滑动时,有没有办法让ViewPager动画简单地淡入淡出?我一直在尝试使用PageTransformer的一些东西,但没有成功,我仍然可以看到它滑动.所以我想我需要以某种方式强迫它的位置保持不变,而滑动我的手指只影响alpha.
public class SecondActivity extends Activity {
SectionsPagerAdapter mSectionsPagerAdapter;
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setPageTransformer(false, new FadePageTransformer());
mViewPager.setAdapter(mSectionsPagerAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar …
Run Code Online (Sandbox Code Playgroud) 这个主题有很多,但我找不到适用于我的情况的实例.
将图片淡出然后淡入另一张图片.相反,我遇到了一个问题,第一个淡出并立即(在动画完成之前)下一个淡入.
我曾经读过这个,并且不记得到底是什么伎俩......
http://jsfiddle.net/danielredwood/gBw9j/
谢谢你的帮助!