有什么方法可以在 Android 中连续放大和缩小 ImageView。我尝试使用下面的代码,但只有一个缩放功能在工作。
缩放.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="20000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="3"
android:toYScale="3" >
</scale>
</set>
缩放.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="20000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5" >
</scale>
</set>
还有我的 Activity 类:
Animation zoomin, zoomout; //declared as public
@Override
public void onCreate(Bundle savedInstanceState) {
// animation
zoomin = AnimationUtils.loadAnimation(this, R.anim.zoomin);
zoomout = AnimationUtils.loadAnimation(this, R.anim.zoomout);
bgImage.setAnimation(zoomin);
bgImage.setAnimation(zoomout);
Thread t = new Thread(new Zoom());
t.start();
}
private class Zoom implements Runnable {
@Override
public void run() {
while (true) {
bgImage.startAnimation(zoomin);
try {
Thread.sleep(8000);
} catch (InterruptedException e) {
e.printStackTrace();
}
bgImage.startAnimation(zoomout);
}
}
}
此处的zoomin 动画似乎运行良好。有没有办法连续实现zoomin和zoomout动画???
谢谢
最佳答案
用这个代替线程
zoomin.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation arg0) {
bgImage.startAnimation(zoomout);
}
});
和
zoomout.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation arg0) {
bgImage.startAnimation(zoomin);
}
});
关于Android ImageView 不断放大和缩小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18231290/
我有一个模块,其中包含名为String的类(以及其他类。)我需要按名称查找该类,如果没有这样的类,则优雅地回退。moduleMod1moduleStringendendMod1.const_get'String'#⇒Mod1::StringKernel.const_get'::Mod1::String'#⇒Mod1::String到目前为止,还不错。当我尝试查找不存在的类时,我预计会收到NameError,这很好。问题是如果在全局命名空间中存在一个具有给定名称的类,它将被返回:Mod1.const_get'Fixnum'#⇒Fixnum我明白其中的原因,但我的问题是:是否有现成的方法仅
场景#1:在下面的示例中,putsPost::User.foo行打印foo。换句话说,Post::User返回一个全局的User常量。classUserdefself.foo"foo"endendclassPostputsPost::User.fooend#=>warning:toplevelconstantUserreferencedbyPost::User#=>foo场景#2:第二个示例会引发错误,因为未找到常量。moduleUserdefself.foo"foo"endendmodulePostputsPost::User.fooend#=>uninitializedconsta
我正在将Rails4.1.8应用程序(也使用rails-api~>0.3.1)升级到4.2.0.rc2,并希望保留respond_with功能。我已将responders添加到Gemfile,但是当我bin/rakespec时,我得到:/Users/sloveless/.gem/ruby/2.1.0/gems/actionpack-4.2.0.rc2/lib/action_controller/metal/mime_responds.rb:10:in`respond_to':Thecontroller-level`respond_to'featurehasbeenextractedto
据我们所知,有很多工具或库可以缩小javascript、css,有没有缩小ruby文件的工具或库?在谷歌搜索后,该问题没有正确答案。非常感谢。 最佳答案 使用Jruby!当把你的应用程序打包成war或jar时,你可以给它传递一个compiled标志,它将把.rb文件编译成java的.class字节码文件Warblerdocumentation 关于ruby-如何缩小ruby文件,我们在StackOverflow上找到一个类似的问题: https://s
我尝试运行gempristine--all并且我不断在控制台中获取它。当我运行gempristine--all我得到这个:权限被拒绝....我什至尝试为每个gem执行geminstall并且仍然得到这个:`Ignoringbinding_of_caller-0.7.2becauseitsextensionsarenotbuilt.Try:gempristinebinding_of_caller--version0.7.2Ignoringbyebug-5.0.0becauseitsextensionsarenotbuilt.Try:gempristinebyebug--version5.
我尝试了以下方法,但是我查看了CSS源代码,它并没有缩小!我重新启动了服务器几十次。我关闭了浏览器中的缓存。我还尝试了'yui-compressor'gem。配置/环境/development.rbconfig.assets.debug=falseconfig.assets.css_compressor=:sassconfig.assets.compile=truegem文件group:assetsdo#Addanycompassextensionshere#UseSCSSforstylesheetsgem'sass-rails','~>4.0.0'引用http://edgeguide
我正在从事一个不会在生产中缩小CSS或JS的项目。不幸的是,我从来没有遇到过这个问题,我只是不太熟悉Assets管道如何详细工作以调试问题。我的问题是,我需要检查哪些要点/设置以确保它已启用?它正确地将不同的文件组合成一个JS和CSS文件……只是没有缩小。到目前为止,我已将config.assets.js_compressor=:uglifier添加到production.rb,并将uglifier添加到Gemfile,但仍然没有骰子。我正在使用从Rails2升级的Rails3.2.12 最佳答案 此答案适用于rails4rails
在我的cucumber支持目录中,我在vcr.rb中有以下内容:require'vcr'VCR.configuredo|c|c.cassette_library_dir='fixtures/vcr_cassettes'c.hook_into:webmockc.ignore_localhost=truec.default_cassette_options={record::new_episodes}end我正在对调用GoogleMapsAPI的城市名称进行地理编码。我正在尝试记录并stub这些请求,但它一直将相同的请求记录到同一个yml文件:-request:method:geturi:
我正在使用dropzone.js用于图片上传。在我的coffeescriptjs文件中,我有dropzone的设置:Dropzone.autoDiscover=falsedropzone=newDropzone('#item-form',maxFiles:1maxFilesize:1paramName:'item[image]'headers:"X-CSRF-Token":$('meta[name="csrf-token"]').attr('content')addRemoveLinks:trueclickable:'#image-preview'previewsContainer:'
我有一个不断增长的日志文件。我如何通过Ruby脚本查看和解析它?脚本将解析写入文件的每个新行,并在新行包含字符串'ERROR'时将内容输出到屏幕 最佳答案 defwatch_for(file,pattern)f=File.open(file,"r")f.seek(0,IO::SEEK_END)whiletruedoselect([f])line=f.getsputs"Foundit!#{line}"ifline=~patternendendwatch_for("g.txt",/ERROR/)感谢ezpz的想法,使用select方法你