第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

動(dòng)畫(huà)上下左右判斷

老師的動(dòng)畫(huà)上下左右判斷錯(cuò)了?Toast的結(jié)果和實(shí)際的不一致

public void changeDataByImageView(final ImageView mImageView) {

// 創(chuàng)建動(dòng)畫(huà),設(shè)置方向、移動(dòng)距離

TranslateAnimation translateAnimation = null;

if (mImageView.getX() > iv_null_ImageView.getX()) {// 在空方塊下面

// 往上移動(dòng)

translateAnimation = new TranslateAnimation(0.1f, -mImageView.getWidth(), 0.1f, 0.1f);

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

} else if (mImageView.getX() < iv_null_ImageView.getX()) {//

// 下

translateAnimation = new TranslateAnimation(0.1f, mImageView.getWidth(), 0.1f, 0.1f);

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

} else if (mImageView.getY() > iv_null_ImageView.getY()) {//

// 左

translateAnimation = new TranslateAnimation(0.1f, 0.1f, 0.1f, -mImageView.getWidth());

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

} else if (mImageView.getY() < iv_null_ImageView.getY()) {//

// 右

translateAnimation = new TranslateAnimation(0.1f, 0.1f, 0.1f, mImageView.getWidth());

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

}

// 設(shè)置動(dòng)畫(huà)時(shí)長(zhǎng)

translateAnimation.setDuration(70);

// 動(dòng)畫(huà)結(jié)束之后停留

translateAnimation.setFillAfter(true);

// 動(dòng)畫(huà)結(jié)束后真正的把數(shù)據(jù)交換

translateAnima


正在回答

2 回答

如果要是按自己的邏輯實(shí)現(xiàn)起來(lái)總是錯(cuò)的,不知道正確的方法。那么可以把a(bǔ)ctivity這個(gè)類的代碼都發(fā)過(guò)來(lái),我結(jié)果上下文看看是不是其它地方寫(xiě)錯(cuò)了

0 回復(fù) 有任何疑惑可以回復(fù)我~

上下左右的問(wèn)題是邏輯問(wèn)題,既然你已經(jīng)知道要用什么方式去判斷了,邏輯問(wèn)題可以自己優(yōu)化一下,只要結(jié)果對(duì)就行。我講的應(yīng)該都沒(méi)問(wèn)題,至少我運(yùn)行起來(lái)是可以玩的沒(méi)發(fā)現(xiàn)問(wèn)題。

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

動(dòng)畫(huà)上下左右判斷

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)