1.無限制放元件量
2資源
文字 TextView
圖片ImageView
版面LinearLayout
3..package com.example.theoryproject1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.*;
public class Viewanimator2 extends Activity
{
private ViewAnimator va1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.viewanimator2);
va1 = (ViewAnimator)findViewById(R.id.viewAnimator1);
Animation inAnim = new AlphaAnimation(0,1);
inAnim.setDuration(2000);
Animation outAnim = new AlphaAnimation(1,0);
outAnim.setDuration(2000);
va1.setInAnimation(inAnim);
va1.setOutAnimation(outAnim);
Button bt1=(Button)findViewById(R.id.button1);
bt1.setOnClickListener(myanilistener9);
}
Button.OnClickListener myanilistener9 = new Button.OnClickListener()
{
@Override
public void onClick(View v) {
va1.showNext();
}
};
}
________________________________
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ViewAnimator
android:id="@+id/viewAnimator1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.6" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="程式設計" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="美工設計" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="資料庫設計" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="手機程式設計" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="網頁設計" />
</ViewAnimator>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="下一資源" />
</LinearLayout>
</LinearLayout>
_______________________________________________
沒有留言:
張貼留言