android - 如何在 Android 中显示动画弹出窗口

标签 android popup android-custom-view

我正在寻找一种方法来制作一个弹出窗口(不是 Dialog),就像在 Whatsapp 中单击个人资料图片时那样。

是这样的。这在 Android 中是如何工作的?我在寻找什么?

如果用户单击我的 ListView header 中的 ImageView,我想显示一些信息。

到目前为止,如果单击 ImageView,我会打开一个新的 Activity。

holder.projectImageImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context1, JobInfo.class);
            intent.putExtra("projectInfo", projectItems);
            intent.putExtra("distributorInfo", distributorItems);
            intent.putExtra("contractorInfo", contractorItems);
            context1.startActivity(intent);
        }
    });

此代码位于扩展 BaseAdapter 的 CustomAdapter 中。

有什么办法可以做我想做的事吗?

亲切的问候!

最佳答案

你可以在样式中设置对话框窗口进入动画和退出动画并且可以在对话框中使用这个设置-

<style name="animationdialog">
    <item name="@android:windowEnterAnimation">@anim/dialog_in</item>
    <item name="@android:windowExitAnimation">@anim/dialog_out</item>
</style>


  dialog = new Dialog(getActivity(),android.R.style.Theme_Holo_Dialog_NoActionBar);
  dialog.setContentView(R.layout.custom_layout_dialog);
  dialog.getWindow().getAttributes().windowAnimations = R.style.animationdialog;

dialog_in.xml

  <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <scale

        android:duration="500"
        android:fromXScale="0.3"
        android:fromYScale="0.3"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="1.0"
        android:toYScale="1.0" />

    <alpha
        android:duration="500"
        android:fromAlpha="0.0"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:toAlpha="1.0" />

</set>

dialog_out.xml

  <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <scale
        android:duration="500"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="0.0"
        android:toYScale="0.0" />

    <alpha
        android:duration="500"
        android:fromAlpha="1.0"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:toAlpha="0.0" />

</set>

关于android - 如何在 Android 中显示动画弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33522470/

相关文章:

javascript - 本站如何打开新窗口

android - 在自定义 RelativeLayout 中居中子项

android - Android 4.4 中的自定义 View 构造函数在 Kotlin 上崩溃,如何修复?

java - 修改自定义 RecyclerView 的项目

android - facebook 和 google 是否有共同的 sso?

android - 在 Android Studio 中使用 Proguard 生成签名 apk 时出现问题

Android为多个 Activity 存储Socket.io对象

android - 为什么在 android setBacklightBrightness(int) 中不起作用

eclipse - 如何在 Eclipse 中将鼠标悬停在代码折叠上时禁用代码预览弹出窗口?

WPF弹出隐藏问题