Android 视图转换动画列表?

发布于 2024-12-16 17:04:40 字数 139 浏览 2 评论 0 原文

是否有可用于在两个视图之间转换的所有动画的列表?即缩放、滑动、面部等。

我似乎无法找到完整的列表,无论是在 SDK 中还是通过搜索 Google。

此外,是否有任何演示应用程序可以显示所有这些内容,以便我可以评估哪个最适合特定用例?

Is there a list of all the animations that I can use to transition between two views? I.e. zoom, slide, face, etc.

I cannot seem to find a comprehensive list, neither in the SDK nor by searching Google.

In addition, is there any demo app that will show all of them, such that I can evaluate which would look best for a specific use case?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江湖正好 2024-12-23 17:04:40

无法创建完整的动画列表。您的想象力是可能的动画数量的限制。

您可以使用可用的基本动画(alpha、缩放、平移和旋转)的任意组合在两个视图之间转换。 可能对您有帮助。

The comprehensive list of animations is not possible to be created. Your imagination is the limit to the number of possible animations.

You can use any combination of the basic animations available(alpha, scale, translate and rotate) to transit between two views. This might help you.

尾戒 2024-12-23 17:04:40

有很多选项可以在视图之间制作动画,其中一些是基本选项,例如 alpha、缩放、平移和旋转,还有在材料设计概念中引入的新选项,用于视图过渡,

您可以在此处找到示例代码,用于视图动画的材料设计 git 参考
https://github.com/lgvalle/Material-Animations

您还可以使用以下方式应用其他动画 这里的anim 资源

是您必须编写的活动代码,

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);

     new Handler().postDelayed(new Runnable() {
         public void run() {

                 /* Create an intent that will start the main activity. */
                 Intent mainIntent = new Intent(SplashScreen.this,
                         ConnectedActivity.class);
                 mainIntent.putExtra("id", "1");

                 //SplashScreen.this.startActivity(mainIntent);
                 startActivity(mainIntent);
                 /* Finish splash activity so user cant go back to it. */
                 SplashScreen.this.finish();

                 /* Apply our splash exit (fade out) and main
                    entry (fade in) animation transitions. */
                 overridePendingTransition(R.anim.mainfadein,R.anim.splashfadeout);
         }
 }, SPLASH_DISPLAY_TIME);   
}

将这两个文件添加到 res/anim 文件夹中。

Slide_in.xml

 <?xml version="1.0" encoding="utf-8"?>
        <translate 
              xmlns:android="http://schemas.android.com/apk/res/android"
              android:duration="@android:integer/config_longAnimTime" 
              android:fromXDelta="100%p" 
              android:toXDelta="0%p">
        </translate>

Slide_out.xml

 <?xml version="1.0" encoding="utf-8"?>
       <translate
             xmlns:android="http://schemas.android.com/apk/res/android" 
             android:duration="@android:integer/config_longAnimTime" 
             android:fromXDelta="0%p" 
             android:toXDelta="-100%p">
      </translate>

我希望这能解决您的疑问

There are many options make animation between views some of are the basic one like alpha, scale, translate and rotate also there new this introduced in the material design concept for view transitions

here you can find sample code the material design git reference for view animation
https://github.com/lgvalle/Material-Animations

You can also apply other animation using anim resource

here is activity code you have to write

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);

     new Handler().postDelayed(new Runnable() {
         public void run() {

                 /* Create an intent that will start the main activity. */
                 Intent mainIntent = new Intent(SplashScreen.this,
                         ConnectedActivity.class);
                 mainIntent.putExtra("id", "1");

                 //SplashScreen.this.startActivity(mainIntent);
                 startActivity(mainIntent);
                 /* Finish splash activity so user cant go back to it. */
                 SplashScreen.this.finish();

                 /* Apply our splash exit (fade out) and main
                    entry (fade in) animation transitions. */
                 overridePendingTransition(R.anim.mainfadein,R.anim.splashfadeout);
         }
 }, SPLASH_DISPLAY_TIME);   
}

Add this two file in res/anim folder.

slide_in.xml

 <?xml version="1.0" encoding="utf-8"?>
        <translate 
              xmlns:android="http://schemas.android.com/apk/res/android"
              android:duration="@android:integer/config_longAnimTime" 
              android:fromXDelta="100%p" 
              android:toXDelta="0%p">
        </translate>

slide_out.xml

 <?xml version="1.0" encoding="utf-8"?>
       <translate
             xmlns:android="http://schemas.android.com/apk/res/android" 
             android:duration="@android:integer/config_longAnimTime" 
             android:fromXDelta="0%p" 
             android:toXDelta="-100%p">
      </translate>

I hope this will be solve your queries

人│生佛魔见 2024-12-23 17:04:40

以下是可在 XML 文件中使用的基本动画的官方文档:
https://developer.android.com/guide/topics/resources/动画资源.html

Here is the official documentation for the basic animations which you can use in XML files:
https://developer.android.com/guide/topics/resources/animation-resource.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文