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

圖片正在播放動畫,圖片可點(diǎn)擊

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

問題描述

我為圖像制作了一個簡單的動畫,并在圖像上設(shè)置了事件 OnClick 來祝酒.問題是我讓圖像開始在 onCreate 上制作動畫,并設(shè)置要單擊的圖像并觸發(fā) toast 但問題是圖像不可點(diǎn)擊,但如果我按下原始位置圖像,吐司開始(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動畫系統(tǒng)的文檔(docs link),特別是 View Animation 和 Property Animation 之間的區(qū)別.以下是來自 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:

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

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.

本質(zhì)上,當(dāng)使用視圖動畫時(shí),視圖本身永遠(yuǎn)不會被翻譯,只會翻譯它被繪制的位置.對象保持在其原始坐標(biāo),這就是為什么您必須點(diǎn)擊舊位置才能獲得事件.這是 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+

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

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

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環(huán)繞文本?)
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 數(shù)據(jù)庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 91精品国产日韩91久久久久久 | 亚洲a视频 | 亚洲国产一区二区三区在线观看 | 久久精品色欧美aⅴ一区二区 | 久久999| 国产一区二区免费 | 欧美日韩一区在线 | www.日本精品| 亚洲精品日韩在线 | 日韩欧美国产成人一区二区 | 亚洲视频在线看 | 亚州中文字幕 | 午夜视频一区 | 夜夜爽夜夜操 | www.夜夜骑 | 欧美在线观看一区 | 污污的网站在线观看 | 国产欧美精品一区二区 | 一区二区三区在线免费观看 | 欧美日韩在线综合 | 蜜桃在线播放 | 一区二区三区韩国 | 久久久久一区二区三区 | 三级视频在线观看电影 | 国产视频线观看永久免费 | 不卡一区| 国产亚洲精品综合一区 | www.成人在线视频 | 成人欧美一区二区三区在线观看 | 人人爽人人爽 | 久久久久久久国产 | 国产一区二区三区免费 | 男女视频免费 | 日韩一区二区三区视频在线观看 | 午夜精品久久久久久久星辰影院 | 中文字幕一级 | 欧美日韩免费一区二区三区 | 高清免费av| www久| 国产精品污www一区二区三区 | 五月综合激情婷婷 |