日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android 按键上浮动画_android – 浮动动作按钮动画

發(fā)布時間:2025/3/11 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 按键上浮动画_android – 浮动动作按钮动画 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

從@Zielony的回答中,我確切地說到了我想要的地方.

下面是正確應用效果的代碼.

scale_fab_in.xml

android:duration="500"

android:fromXScale="0"

android:fromYScale="0"

android:pivotX="50%"

android:pivotY="50%"

android:toXScale="1"

android:toYScale="1"

android:interpolator="@android:interpolator/overshoot"/>

scale_fab_out.xml

android:duration="400"

android:fromXScale="1"

android:fromYScale="1"

android:pivotX="50%"

android:pivotY="50%"

android:toXScale="0"

android:toYScale="0"

android:interpolator="@android:interpolator/overshoot"/>

編輯2016年2月16日 – 另一種方式:

將下面的代碼放在您的FAB代碼或任何其他視圖中.

//global

private static final int FAB_ANIM_DURATION = 200;

public void hide() {

// Only use scale animation if FAB is visible

if (getVisibility() == View.VISIBLE) {

// Pivots indicate where the animation begins from

float pivotX = getPivotX() + getTranslationX();

float pivotY = getPivotY() + getTranslationY();

// Animate FAB shrinking

ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, pivotX, pivotY);

anim.setDuration(FAB_ANIM_DURATION);

anim.setInterpolator(getInterpolator());

startAnimation(anim);

}

setVisibility(View.INVISIBLE);

}

public void show() {

show(0, 0);

}

public void show(float translationX, float translationY) {

// Set FAB's translation

setTranslation(translationX, translationY);

// Only use scale animation if FAB is hidden

if (getVisibility() != View.VISIBLE) {

// Pivots indicate where the animation begins from

float pivotX = getPivotX() + translationX;

float pivotY = getPivotY() + translationY;

ScaleAnimation anim;

// If pivots are 0, that means the FAB hasn't been drawn yet so just use the

// center of the FAB

if (pivotX == 0 || pivotY == 0) {

anim = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f,

Animation.RELATIVE_TO_SELF, 0.5f);

} else {

anim = new ScaleAnimation(0, 1, 0, 1, pivotX, pivotY);

}

// Animate FAB expanding

anim.setDuration(FAB_ANIM_DURATION);

anim.setInterpolator(getInterpolator());

startAnimation(anim);

}

setVisibility(View.VISIBLE);

}

private void setTranslation(float translationX, float translationY) {

if (Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1) {

animate().setInterpolator(getInterpolator()).setDuration(FAB_ANIM_DURATION)

.translationX(translationX).translationY(translationY);

}

}

private Interpolator getInterpolator() {

return AnimationUtils.loadInterpolator(getContext(), R.interpolator.fab_interpolator);

}

@android:interpolator/decelerate_cubic

總結(jié)

以上是生活随笔為你收集整理的android 按键上浮动画_android – 浮动动作按钮动画的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。