2016-04-01 8 views
15

enter image description hereएंड्रॉइड सामग्री डिजाइन में निम्न एनीमेशन कैसे प्राप्त करें?

एंड्रॉइड में इस एनीमेशन को प्राप्त करना चाहते हैं। किसी भी मदद की व्याख्या करें।

+2

मुझे लगता है कि यह 'प्रकटन प्रभाव' के साथ एक साधारण अनुवाद एनीमेशन है http://developer.android.com/training/material/animations.html#Reveal –

+0

संभावित डुप्लिकेट [एंड्रॉइड गतिविधि का उपयोग करके फ़्लोटिंग एक्शन बटन को एनिमेट करने के लिए कैसे करें संक्रमण?] (http://stackoverflow.com/questions/29846458/how-to-animate-floating-action-button-using-android-activity-transition) –

उत्तर

1

मैंने इसका परीक्षण नहीं किया है लेकिन इसे काम करना चाहिए।

LinearLayout mRevealView; 
boolean hidden = true; 

अपने onCreate विधि में इस जोड़ें::

mRevealView = (LinearLayout) findViewById(R.id.reveal_items); 
mRevealView.setVisibility(View.INVISIBLE); 

compile 'com.github.ozodrukh:CircularReveal:1.1.1'

अपनी गतिविधि की शुरुआत में इन चरों घोषित:

Gradle फ़ाइल आपकी ऐप्लिकेशन को यह निर्भरता जोड़ें अपने एफएबी की ऑनक्लिक विधि में, इसे जोड़ें:

int cx = (mRevealView.getLeft() + mRevealView.getRight()); 
     int cy = mRevealView.getTop(); 
     int radius = Math.max(mRevealView.getWidth(), mRevealView.getHeight()); 

     //Below Android LOLIPOP Version 
     if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { 
      SupportAnimator animator = 
        ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius); 
      animator.setInterpolator(new AccelerateDecelerateInterpolator()); 
      animator.setDuration(700); 

      SupportAnimator animator_reverse = animator.reverse(); 

      if (hidden) { 
       mRevealView.setVisibility(View.VISIBLE); 
       animator.start(); 
       hidden = false; 
      } else { 
       animator_reverse.addListener(new SupportAnimator.AnimatorListener() { 
        @Override 
        public void onAnimationStart() { 

        } 

        @Override 
        public void onAnimationEnd() { 
         mRevealView.setVisibility(View.INVISIBLE); 
         hidden = true; 

        } 

        @Override 
        public void onAnimationCancel() { 

        } 

        @Override 
        public void onAnimationRepeat() { 

        } 
       }); 
       animator_reverse.start(); 
      } 
     } 
     // Android LOLIPOP And ABOVE Version 
     else { 
      if (hidden) { 
       Animator anim = android.view.ViewAnimationUtils. 
         createCircularReveal(mRevealView, cx, cy, 0, radius); 
       mRevealView.setVisibility(View.VISIBLE); 
       anim.start(); 
       hidden = false; 
      } else { 
       Animator anim = android.view.ViewAnimationUtils. 
         createCircularReveal(mRevealView, cx, cy, radius, 0); 
       anim.addListener(new AnimatorListenerAdapter() { 
        @Override 
        public void onAnimationEnd(Animator animation) { 
         super.onAnimationEnd(animation); 
         mRevealView.setVisibility(View.INVISIBLE); 
         hidden = true; 
        } 
       }); 
       anim.start(); 
      } 
     } 

अपनी गतिविधि के लिए इस विधि जोड़ें:

<io.codetail.widget.RevealFrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginTop="?attr/actionBarSize"> 

    //You can include whatever layout you want here 
    <include layout="@layout/layout_you_want_to_show" /> 

</io.codetail.widget.RevealFrameLayout> 

इसके लिए काम करने के लिए है, यह है:

private void hideRevealView() { 
    if (mRevealView.getVisibility() == View.VISIBLE) { 
     mRevealView.setVisibility(View.INVISIBLE); 
     hidden = true; 
    } 
} 

प्रकट करते हैं, कहते हैं यह reveal_layout.xml और इस ऐड के लिए एक नया XML लेआउट बनाएं अनिवार्य है कि आप इसे अपनी गतिविधियों के लेआउट के अंत में जोड़ते हैं:

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <include layout="@layout/reveal_layout" /> 

</FrameLayout> 

आशा है कि इससे मदद मिलती है।

संबंधित मुद्दे