免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

Android-圖形圖像與動畫之Animation實現圖像的漸變、縮放、位移、旋轉的代碼

把代碼過程重要的一些代碼做個記錄,下面代碼是關于Android-圖形圖像與動畫之Animation實現圖像的 漸變、縮放、位移、旋轉的代碼。

成都創新互聯公司專注為客戶提供全方位的互聯網綜合服務,包含不限于成都網站建設、網站設計、寧蒗網絡推廣、小程序開發、寧蒗網絡營銷、寧蒗企業策劃、寧蒗品牌公關、搜索引擎seo、人物專訪、企業宣傳片、企業代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;成都創新互聯公司為所有大學生創業者提供寧蒗建站搭建服務,24小時服務熱線:18980820575,官方網址:m.newbst.com

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
<Button
    android:id="@+id/button_scale"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="scale"
    android:layout_x="5dp"
    android:layout_y="383dp" />
<Button
    android:id="@+id/button_rotate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="rotate"
    android:layout_x="158dp"
    android:layout_y="383dp" />
<Button
    android:id="@+id/button_alpha"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="alpha"
    android:layout_x="5dp"
    android:layout_y="331dp" />
<Button
    android:id="@+id/button_translate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="translate"
    android:layout_x="160dp"
    android:layout_y="329dp" />
<Button
    android:id="@+id/button_alpha_translate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="alpha_translate"
    android:layout_x="84dp"
    android:layout_y="265dp" />

<ImageView
    android:id="@+id/imageview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="105dp"
    android:layout_y="133dp" 
    android:src="@drawable/ic_launcher"
    />
</AbsoluteLayout>

實現本實例的源代碼如下:

public class Animations_Activity extends Activity {
    private Button button1;
    private Button button2;
    private Button button3;
    private Button button4;
    private Button button5;
    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_animations_);
        button1=(Button)findViewById(R.id.button_alpha);
        button2=(Button)findViewById(R.id.button_rotate);
        button3=(Button)findViewById(R.id.button_scale);
        button4=(Button)findViewById(R.id.button_translate);
        button5=(Button)findViewById(R.id.button_alpha_translate);
        imageView=(ImageView)findViewById(R.id.imageview);
        button1.setOnClickListener(new MyButton());
        button2.setOnClickListener(new MyButton());
        button3.setOnClickListener(new MyButton());
        button4.setOnClickListener(new MyButton());
        button5.setOnClickListener(new MyButton());
    }
    class MyButton implements OnClickListener{

        @Override
        public void onClick(View arg0) {
            switch (arg0.getId()) {
            case R.id.button_alpha:
                Alpha();
                break;
            case R.id.button_rotate:
                Rotata();
                break;
            case R.id.button_scale:
                Scale();
                break;
            case R.id.button_translate:
                Translate();
                break;
            case R.id.button_alpha_translate:
                Alpha_Translate();
                break;

            default:
                break;
            }
        }

    }

    public void Alpha() {
        AnimationSet animationSet=new AnimationSet(true);
        AlphaAnimation alphaAnimation=new AlphaAnimation(1, 0);
        alphaAnimation.setDuration(2000);
        animationSet.addAnimation(alphaAnimation);
        imageView.startAnimation(animationSet);
    }
    public void Rotata(){
        AnimationSet animationSet=new AnimationSet(true);
        RotateAnimation rotateAnimation=new RotateAnimation(
                0, 360, 
                Animation.RELATIVE_TO_PARENT, 1f,
                Animation.RELATIVE_TO_PARENT, 0f);
        rotateAnimation.setDuration(2000);
        animationSet.addAnimation(rotateAnimation);
        imageView.startAnimation(animationSet);
    }
    public void Scale() {
        AnimationSet animationSet=new AnimationSet(true);
        ScaleAnimation scaleAnimation=new ScaleAnimation(
                1, 0.1f, 1, 0.1f, 
                Animation.RELATIVE_TO_SELF, 0.5f, 
                Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setDuration(2000);
        animationSet.addAnimation(scaleAnimation);
        imageView.startAnimation(scaleAnimation);
    }
    public void Translate() {
        AnimationSet animationSet=new AnimationSet(true);
        TranslateAnimation translateAnimation=new TranslateAnimation(
        translateAnimation.setDuration(2000);
        animationSet.addAnimation(translateAnimation);

        animationSet.setFillAfter(true);
        animationSet.setFillBefore(false);
        animationSet.setStartOffset(2000);
        animationSet.setRepeatCount(3);

        imageView.startAnimation(animationSet);
    }
    public void Alpha_Translate() {
        AnimationSet animationSet=new AnimationSet(true);
        AlphaAnimation alphaAnimation=new AlphaAnimation(1, 0);
        alphaAnimation.setDuration(2000);
        animationSet.addAnimation(alphaAnimation);
        TranslateAnimation translateAnimation=new TranslateAnimation(
        translateAnimation.setDuration(2000);
        animationSet.addAnimation(translateAnimation);
        imageView.startAnimation(animationSet);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_animations_, menu);
        return true;
    }

}

當前文章:Android-圖形圖像與動畫之Animation實現圖像的漸變、縮放、位移、旋轉的代碼
當前地址:http://m.newbst.com/article12/ijsigc.html

成都網站建設公司_創新互聯,為您提供營銷型網站建設小程序開發微信公眾號微信小程序企業建站

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都網頁設計公司