国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > Android > 正文

Android開(kāi)啟動(dòng)畫之漸隱漸現(xiàn)效果

2019-12-12 00:44:55
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

啟動(dòng)某項(xiàng)程序時(shí)我們往往都能看到不同的“開(kāi)機(jī)動(dòng)畫”,千變?nèi)f化的動(dòng)畫也只不過(guò)是四種基本動(dòng)畫衍變美化而成的。

四種android動(dòng)畫效果:

  • alpha         漸變透明度動(dòng)畫效果
  • scale         漸變尺寸伸縮動(dòng)畫效果
  •  translate  畫面轉(zhuǎn)換位置移動(dòng)動(dòng)畫效果
  • rotate        畫面轉(zhuǎn)移旋轉(zhuǎn)動(dòng)畫效果

最簡(jiǎn)單的莫過(guò)于漸變透明效果,單單這一種就可完成漸隱漸現(xiàn)的動(dòng)畫效果(用于漸現(xiàn)漸隱的可以是整個(gè)歡迎頁(yè)面也可以是歡迎頁(yè)面里的一部分):

1)、 在res里新建anim文件夾用來(lái)盛放動(dòng)畫定義的動(dòng)作文件:

<set xmlns:android="http://schemas.android.com/apk/res/android"    android:interpolator="@android:anim/accelerate_interpolator">    <alpha       android:fromAlpha="0.0"      android:toAlpha="1.0"      android:duration="2000"/>    <alpha       android:fromAlpha="1.0"      android:toAlpha="0.0"      android:startOffset="3000"      android:duration="3000"/>  </set>

fromalpha即開(kāi)始的透明度,toalpha即結(jié)束時(shí)的透明度,duration為時(shí)間(單位毫秒)。

2)、定義布局文件(layout):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:gravity="center_vertical|center_horizontal"  android:orientation="vertical" >   <ImageView    android:id="@+id/welcom_logo"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:src="@drawable/welcome" /> </LinearLayout>

這里和以往沒(méi)有任何不同,只需對(duì)要漸現(xiàn)漸隱的圖片進(jìn)行id標(biāo)示。

3)、實(shí)現(xiàn)方法(Activity):

public class WelcomeActivity extends Activity implements AnimationListener { private ImageView imageView = null; private Animation alphaAnimation = null;  @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); imageView = (ImageView) findViewById(R.id.welcom_logo); alphaAnimation = AnimationUtils.loadAnimation(this,  R.anim.welcome_alpha); alphaAnimation.setFillEnabled(true);//啟動(dòng)Fill保持 alphaAnimation.setFillAfter(true);//設(shè)置動(dòng)畫的最后一幀是保留在view上的 imageView.setAnimation(alphaAnimation); alphaAnimation.setAnimationListener(this);  }  @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_welcome, menu); return true; }  @Override public void onAnimationEnd(Animation animation) { //動(dòng)畫結(jié)束時(shí)結(jié)束歡迎頁(yè)面并跳轉(zhuǎn)到主頁(yè)面 Intent intent=new Intent(this,GroupActivity.class); startActivity(intent); this.finish();  }  @Override public void onAnimationRepeat(Animation animation) {   }  @Override public void onAnimationStart(Animation animation) {   } public boolean onKeyDown(int KeyCode,KeyEvent event){ //在歡迎頁(yè)面屏蔽BACK鍵 if(KeyCode==KeyEvent.KEYCODE_BACK){  return false; } return false;  }}

歡迎頁(yè)面顧名思義只是裝飾作用一閃而過(guò)不需要返回鍵進(jìn)行操作。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 大宁县| 黄龙县| 修武县| 昭觉县| 甘谷县| 乌拉特后旗| 萝北县| 闸北区| 濮阳县| 额尔古纳市| 江孜县| 宣武区| 通河县| 顺平县| 慈利县| 浦东新区| 庐江县| 浙江省| 长子县| 林周县| 广饶县| 尤溪县| 浦北县| 工布江达县| 临朐县| 顺昌县| 西充县| 永登县| 安西县| 鹿泉市| 双桥区| 湖口县| 迁安市| 仁怀市| 清丰县| 江口县| 芒康县| 吴堡县| 邮箱| 乾安县| 章丘市|