Android 材料设计布局动画

Android 材料设计布局动画,android,animation,material-design,Android,Animation,Material Design,Android L的一个想法是,弹出窗口需要从用户点击屏幕的位置开始幻影。 例如,在Chrome Beta(@time*5)中: 其想法是能够使视图从任何轴点(而不仅仅是溢出按钮的预定位置)开始增长 有没有人能够做到这一点,或者目前还不可行?好吧,我想从总体上看,制作一个动画应该适合你 为此,请执行以下代码: RecyclerView view = (RecyclerView) findViewById(R.id.your_view); Animation appear = Animation

Android L的一个想法是,弹出窗口需要从用户点击屏幕的位置开始幻影。
例如,在Chrome Beta(@time*5)中:

其想法是能够使视图从任何轴点(而不仅仅是溢出按钮的预定位置)开始增长
有没有人能够做到这一点,或者目前还不可行?

好吧,我想从总体上看,制作一个动画应该适合你

为此,请执行以下代码:

RecyclerView view = (RecyclerView) findViewById(R.id.your_view);
Animation appear = AnimationUtils.loadAnimation(this, R.anim.appear);
apear.startAnimation(view);
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:android:fromXScale="0"
        android:toXScale="1.0"
        android:fromYScale="0"
        android:toYScale="1.0"
        android:duration="1000" />
</set>
然后,在res/anim文件夹中(如果不存在,则创建它),创建一个名为appease.xml的xml文件,并输入以下代码:

RecyclerView view = (RecyclerView) findViewById(R.id.your_view);
Animation appear = AnimationUtils.loadAnimation(this, R.anim.appear);
apear.startAnimation(view);
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:android:fromXScale="0"
        android:toXScale="1.0"
        android:fromYScale="0"
        android:toYScale="1.0"
        android:duration="1000" />
</set>

根据您的目的更改值


您可以在《android开发者参考和API指南》中获得更多信息。

似乎没有干净的方法可以做到这一点。
我发现的唯一可行的选择是编写4个不同的xml动画(对于4个角,如果您想允许居中增长,则更多),所有从0到1的缩放动画,每个(4个角)具有不同的轴心点

然后,使用
对话框片段

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) 
{
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.getWindow().getAttributes().windowAnimations = 
         R.style.downRightCornerAnimation;
    //instead of referring to R.*, call a method to get the specific
    //resource you need for a given start position
    return dialog;
}
这种动画的一个例子是:

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/linear_interpolator"
       android:fromXScale="0.0"
       android:toXScale="1.0"
       android:fromYScale="0.0"
       android:toYScale="1.0"
       android:fillAfter="false"
       android:duration="200" 
       android:pivotX = "0%"
       android:pivotY = "100%"/>   


这是一个非常笨拙和粗糙的工具,但我不认为SDK为我们提供了更好的工具来实现这一点(好吧,你不能只在
对话框片段
弹出窗口
)中插入一个动态
ObjectAnimator

你想在listview项目上应用这个动画吗?或者只是在一个简单的视图上?发布一个你想要的视频肯定会有帮助<代码>adb外壳屏幕记录?@Vikram好主意,可以。