简体   繁体   English

整个应用程序中的Android后退箭头动画

[英]Android Back Arrow Animation throughout entire Application

I have successfully achieved the Drawer Hamburger/ Arrow Spin Navigation in Home Activity. 我已经在家庭活动中成功实现了“抽屉汉堡/箭头旋转导航”。

It is working fine but is limited to that specific activity . 它工作正常,但仅限于该特定活动

When I start an intent to Activity B I am unable to do the same spin animation. 当我开始进行活动B时,我无法执行相同的旋转动画。

Can I use it in my entire app, Just like Google Play. 我可以像Google Play一样在我的整个应用程序中使用它吗? And how to do it? 以及如何做?

  1. You can create a base activity and extend all other activities from it. 您可以创建基本活动并从中扩展所有其他活动。
  2. In base activity you need to override setcontentview(View view) method. 在基本活动中,您需要重写setcontentview(View view)方法。
  3. You can have your working Drawer Hamburger code of Activity A in base activity. 您可以在基本活动中拥有活动A的有效抽屉汉堡代码。
  4. You should have a container view inside your layout of base activity. 您在基本活动的布局内应该有一个容器视图。
  5. Lets say Activity A extends BaseActivity so in oncreate of Activity A you will do setContentView (childview); 可以说活动A扩展了BaseActivity,因此在活动A的oncreate中,您将执行setContentView(childview); Now this will give call to overrided method of BaseActivity. 现在,这将调用BaseActivity的重写方法。 Lets say BaseActivity has layout abc.xml with containerview. 可以说BaseActivity具有带有containerview的布局abc.xml。

  6. Add this view to the container. 将此视图添加到容器。 Inflate from abc.xml and put it in view. 从abc.xml进行膨胀并将其显示。

  7. From view do containerview = view.findViewById(R.id.container). 从视图执行containerview = view.findViewById(R.id.container)。
  8. Lets say container is linear layout. 可以说容器是线性布局。 Now you do containerview.addView(child) 现在您要做containerview.addView(child)
  9. Give call to super.setcontentview(view); 调用super.setcontentview(view);
  10. Now for each and every activity you need to just extend from base activity and do setcontentview on it. 现在,对于每个活动,您只需要从基本活动扩展并在其上进行setcontentview即可。

This is it. 就是这个。 You can have a common layout structure throughout apps. 您可以在整个应用程序中使用通用的布局结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM