原创
按钮动态效果:
1.在res--drawable--新建一个XML文件。 这里就举例按钮和默认效果,还有其他效果就不写了。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 按下图片-->
<item android:drawable="@drawable/button2" android:state_pressed="true" />
<!-- 默认图片-->
<item android:drawable="@drawable/button1" />
</selector>
2.在activity_main.xml里设置该按钮的属性,如果不是英文单词会提示文字有误,不用管
android:background="@drawable/happy"
还有一种在代码里直接修改图片的:myButton.setImageDrawable(getResources().getDrawable(R.drawable.button1));动画效果:import android.view.animation.Animation; --动画包 import android.view.animation.AlphaAnimation; --透明动画包 import android.view.animation.ScaleAnimation; --大小动画包Animation animation=new AlphaAnimation(1.0f,0.0f); animation.setDuration(3000); myButton.startAnimation(animation); Animation animation3 =new ScaleAnimation(0.8f,0.8f,0.8f,0.8f); animation3.setDuration(100); myButton.startAnimation(animation3);
</pre><pre code_snippet_id="1869097" snippet_file_name="blog_20160906_3_6083167" name="code" class="java"><pre name="code" class="java"> animation01.setRepeatCount(Animation.INFINITE); //重复次数 animation01.setDuration(1200); //持续时间 animation01.setStartOffset(3600); //多久后开始 animation01.setRepeatMode(Animation.REVERSE); //重复模式
<pre style="font-family: 宋体; font-size: 12pt; background-color: rgb(255, 255, 255);">animation.setFillAfter(<span style="color:#000080;"><strong>true</strong></span>); //动画结束保持状态
//动画事件 animation01.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { jiantou01.setAlpha(0f); } @Override public void onAnimationEnd(Animation animation) { jiantou01.setAlpha(1f); } @Override public void onAnimationRepeat(Animation animation) { } });
题外话:U3D显示帧率和内存消耗 fps.ToString("f0") Profiler.GetTotalAllocatedMemory() / 1024 / 1024计算出来是MB