私はAndroidアプリケーションでボトムシートを使用しています。 ボトムシートをロードするための循環表示アニメーションを追加するにはどうすればよいですか?BottomSheetに円形の公開アニメーションを追加します。
1)アニメーションのコードを公開してください: createCircularReveal
は、上記の21個のAPIにアニメーションを上にスライドするアニメーションまで、あなたの通常のスライドを変換するために、21
私はAndroidアプリケーションでボトムシートを使用しています。 ボトムシートをロードするための循環表示アニメーションを追加するにはどうすればよいですか?BottomSheetに円形の公開アニメーションを追加します。
1)アニメーションのコードを公開してください: createCircularReveal
は、上記の21個のAPIにアニメーションを上にスライドするアニメーションまで、あなたの通常のスライドを変換するために、21
シンプルなロジックよりも上位のAPIレベルを持つすべてのデバイスをサポートしているAndroidのSDKの機能ですビューのために。
bottomSheetDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
revealShow(bsdCreateNewBinding.getRoot(), true, null);
}
});
:あなたのダイアログの親ビューを取得し、.SHOW()メソッド
((View) bsdCreateNewBinding.getRoot().getParent()).setBackgroundColor(Color.TRANSPARENT);
3)この方法でアニメーションを明らかに適用する前透明にその背景を変更
2)公開動画コードは次のとおりです。
private void revealShow(View dialogView, boolean b, final BottomSheetDialog dialog) {
final View view = dialogView.findViewById(R.id.dialog);
int w = view.getWidth();
int h = view.getHeight();
int endRadius = (int) Math.hypot(w, h);
int cx = (int) (binding.btnAdd.getX() + (binding.btnAdd.getWidth()/2));
int cy = (int) (binding.btnAdd.getY()) + binding.btnAdd.getHeight() + 56;
if (b) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Animator revealAnimator = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, endRadius);
view.setVisibility(View.VISIBLE);
revealAnimator.setDuration(700);
revealAnimator.start();
} else {
view.setVisibility(View.VISIBLE);
}
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Animator anim =
ViewAnimationUtils.createCircularReveal(view, cx, cy, endRadius, 0);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
dialog.dismiss();
view.setVisibility(View.INVISIBLE);
}
});
anim.setDuration(700);
anim.start();
} else {
dialog.dismiss();
view.setVisibility(View.INVISIBLE);
}
}
}
P.S:下および上のLolipopケースを扱った。ここで
は、アニメーションを公開してダイアログやBottomSheetDialogための完璧な例です:https://android.jlelse.eu/custom-dialog-with-circular-reveal-animation-ef7dc77ba1e
あなたがこれまでに試してみましたか? –
私はcom.github.rey5137のBottomSheetDialog を使用しました:材料 ライブラリ。それは私たちがスタイルからit.iにアニメーションを設定することができるスタイルIDを持っていますアンドロイド21 +のためのリバイバルアニメーションを設定したい。 21-apiレベルのデバイスでは、スタイルからアニメーションを設定できます。 –
申し訳ありませんが、私はそれをお手伝いできません。おそらく彼らのgithubページで助けを求める。 –