久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

圖片正在播放動畫,圖片可點擊

image is playing an animation and the image is clickable(圖片正在播放動畫,圖片可點擊)
本文介紹了圖片正在播放動畫,圖片可點擊的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我為圖像制作了一個簡單的動畫,并在圖像上設置了事件 OnClick 來祝酒.問題是我讓圖像開始在 onCreate 上制作動畫,并設置要單擊的圖像并觸發 toast 但問題是圖像不可點擊,但如果我按下原始位置圖像,吐司開始(onClick沒有隨著動畫移動)

I've made a simple animation for an image and I set the event OnClick on the image to make a toast. The problem is that I made the image started doing the animation on the onCreate and I made set the image to be clicked and fire the toast but the problem is that the image isn't clickable, but if I press on the original position of the image, the toast is started (the onClick is not moving with the animation)

感謝您的幫助

這是anim文件夾中的動畫代碼(translate.xml)

this is the animation code in anim folder (translate.xml)

<?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
      android:interpolator="@android:anim/linear_interpolator" >
    <translate
        android:duration="1500"
        android:fromXDelta="-100%p"
        android:repeatCount="0"
        android:repeatMode="reverse"
        android:toXDelta="0" />

    </set>

這是活動類

package com.example.animatest;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends Activity {

private ImageView image01;

private long aefe;
private ImageView image1;
private ImageView image2;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    image01 = (ImageView) findViewById(R.id.imageView1);

    final Animation animTranslate1 = AnimationUtils.loadAnimation(this,
            R.anim.translate);

    image01.startAnimation(animTranslate1);

    image01.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {

            Toast.makeText(MainActivity.this, "hello", Toast.LENGTH_SHORT)
                    .show();

        }
    });

}

}

推薦答案

閱讀Android動畫系統的文檔(docs link),特別是 View Animation 和 Property Animation 之間的區別.以下是來自 View Animation 文檔的引用:

Have a read over the documentation for the Android animation system (docs link), specifically the difference between View Animation and Property Animation. Here is a quote from the View Animation doc:

注意:無論您的動畫如何移動或調整大小,保存動畫的 View 的邊界都不會自動調整以適應它.

Note: Regardless of how your animation may move or resize, the bounds of the View that holds your animation will not automatically adjust to accommodate it.

本質上,當使用視圖動畫時,視圖本身永遠不會被翻譯,只會翻譯它被繪制的位置.對象保持在其原始坐標,這就是為什么您必須點擊舊位置才能獲得事件.這是 View Animation 的一個已知限制,也是在 Android 3.0+ 中引入 Property Animation 的原因之一

Essentially, when using View Animation, the view itself is never translated, only the location at which it is drawn. The object remains at its original coordinates, which is why you have to tap the old location to get an event. This is a known limitation of View Animation and is one of the reasons Property Animation was introduced in Android 3.0+

這篇關于圖片正在播放動畫,圖片可點擊的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 超碰免费在线 | 亚洲第1页| 欧美一级黄色片免费观看 | av在线天天| 久草精品在线 | www.成人.com| 国产精品爱久久久久久久 | 91久久精品一区二区三区 | 国产免费拔擦拔擦8x高清 | 国产三级一区二区三区 | 97国产一区二区精品久久呦 | 午夜免费网站 | 亚洲日韩中文字幕一区 | 99国产精品99久久久久久粉嫩 | 欧美亚洲视频 | 国产综合久久 | 欧美成视频 | 日本粉嫩一区二区三区视频 | 伊人无码高清 | 国产一区二区在线免费 | 国产精品久久久久久av公交车 | 久久久精品亚洲 | 欧美在线一区二区三区 | 国产福利在线 | 国内精品久久久久久久影视简单 | 日韩电影一区 | 99热在这里只有精品 | 久久久久久999 | 亚洲综合在线网 | 国产精品污污视频 | 欧美一级全黄 | 欧美三级三级三级爽爽爽 | 黄色高清视频 | 中文字幕亚洲精品 | 国产成人在线播放 | 九九九精品视频 | 欧美午夜精品 | 日本福利视频免费观看 | 久久久久久久久久毛片 | 免费在线观看成年人视频 | 在线国产中文字幕 |