2017-12-07 8 views
1

SplashScreen 액티비티에서 MainActivity로 전환하는 버튼 클릭에 대한 원형 공개 애니메이션을 적용하려고합니다. 사람들이 제공 한 거의 모든 솔루션을 시도했지만 액티비티 변경에 대한 원형 공개와 같은 사용자 지정 애니메이션을 만드는 개념을 이해할 수는 없습니다. 현재 활동보기에 성공적으로 적용 할 수 있지만 활동 전환에는 적용 할 수 없습니다.활동 변경에 순환 노출을 적용하는 방법은 무엇입니까?

는 여기에 사용자 지정 애니메이션 (CircularReveal) 버튼을 클릭하고 MainActivity로되는 SplashScreen 전환을 만들고 싶어 내 SplashScreen.java

public class SplashScreen extends AppCompatActivity { 
    boolean isOpen = false; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 


     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_splash_screen); 
     final ImageButton startButton = (ImageButton) findViewById(R.id.button); 
     final TextView textView = (TextView)findViewById(R.id.tv1); 
     fadeInTextView(textView); 
     circularRevealDelayedImageButton(startButton); 

    } 


    public void fadeInTextView(final TextView textView){ 
     textView.postDelayed(new Runnable() { 
      @Override 
      public void run() { 
       final TextSwitcher textSwitcher = (TextSwitcher)findViewById(R.id.ssj1); 
       textSwitcher.setFactory(new ViewSwitcher.ViewFactory() { 

        public View makeView() { 
         // TODO Auto-generated method stub 
         // create a TextView 
         TextView t = new TextView(SplashScreen.this); 
         // set the gravity of text to top and center horizontal 
         // set displayed text size 
         Resources r = getResources(); 
         float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 23, r.getDisplayMetrics()); 
         t.setTextSize(px); 
         t.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); 
         t.setPadding(0,240,0,0); 
         Typeface type = Typeface.createFromAsset(getAssets(),"fonts/allura.ttf"); 
         t.setTypeface(type); 
         t.setTextColor(getResources().getColor(R.color.black)); 
         return t; 
        } 
       }); 
       Animation anim = AnimationUtils.loadAnimation(getApplicationContext(),android.R.anim.fade_in); 
       textView.setVisibility(View.VISIBLE); 
       textView.setAnimation(anim); 
       textSwitcher.postDelayed(new Runnable() { 
        @Override 
        public void run() { 
         textSwitcher.setText("Hey There\nJaadi :)"); 
        } 
       },2000); 

       textSwitcher.postDelayed(new Runnable() { 
        @Override 
        public void run() { 
         textSwitcher.setText(""); 
        } 
       },7000); 
       textSwitcher.postDelayed(new Runnable() { 
        @Override 
        public void run() { 
         textSwitcher.setText("Press That\nHeart\nFor Me"); 
        } 
       },9000); 


      } 
     },3000); 


    } 


    public void circularRevealDelayedImageButton(final ImageButton startButton){ 
     startButton.postDelayed(new Runnable() { 
      @Override 
      public void run() { 
       // get the center for the clipping circle 
       int cx = startButton.getWidth()/2; 
       int cy = startButton.getHeight()/2; 

// get the final radius for the clipping circle 
       float finalRadius = (float) Math.hypot(cx, cy); 

// create the animator for this view (the start radius is zero) 
       Animator anim = 
         ViewAnimationUtils.createCircularReveal(startButton, cx, cy, 0, finalRadius); 

// make the view visible and start the animation 
       startButton.setVisibility(View.VISIBLE); 
       anim.setDuration(350); 
       anim.start(); 
       startButton.setOnClickListener(new View.OnClickListener() { 
        @Override 
        public void onClick(View view) { 
         startActivity(new Intent(SplashScreen.this, MainActivity.class)); 
         // WHAT TO ADD HERE??? FOR CIRCULAR REVEAL ANIMATION FOR THE ABOVE INTENT??? 
        } 
       }); 
      } 
     },13000); 
    } 


    } 

입니다. 코드를 설명 할 수 있다면 좋을 것입니다. 나는 하루 동안이 문제에 대한 해결책을 얻으려고 노력 중이며 여전히 아무 것도 얻을 수 없다. 또한 변경 XML

에서 수행 될 필요가 제안 여기 여기

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:id="@+id/layoutcontent" 
    android:visibility="invisible" 
    android:transitionName="transition" 
    android:layout_height="match_parent" 
    tools:context="com.yourstrulyssj.foru.MainActivity"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" /> 

</RelativeLayout> 

MainActivity.xml

의 당신은이 링크를 사용할 수 있습니다

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/layoutmain" 
    android:transitionName="transition" 
    tools:context="com.yourstrulyssj.foru.SplashScreen"> 
    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/rwall" 
     android:scaleType="centerCrop" 

     /> 

    <TextSwitcher 
     android:id="@+id/ssj1" 
     android:layout_width="300dip" 
     android:layout_height="400dip" 

     android:layout_alignStart="@+id/tv1" 
     android:layout_alignTop="@+id/tv1" 
     android:inAnimation="@android:anim/fade_in" 
     android:outAnimation="@android:anim/fade_out"> 

    </TextSwitcher> 

    <TextView 
     android:id="@+id/tv1" 
     android:layout_width="300dip" 
     android:layout_height="400dip" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="51dp" 
     android:background="@drawable/back1" 
     android:fontFamily="cursive" 
     android:gravity="center" 
     android:text="" 
     android:textSize="80dip" 
     android:visibility="invisible" /> 

    <ImageButton 
     android:id="@+id/button" 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="26dp" 
     android:layout_weight="1" 
     android:background="@drawable/roundedbutton" 
     android:src="@drawable/ic_favorite_black_24dp" 
     android:visibility="invisible" /> 
</RelativeLayout> 

답변

0

내 SplashScreen.xml인가 : 여기 presentActivity 당신에게 아이디어를 제공 한 클래스에서 다른 클래스로 이동하는 동안 효과를 발생시키는 방법.

https://android.jlelse.eu/a-little-thing-that-matter-how-to-reveal-an-activity-with-circular-revelation-d94f9bfcae28

은 당신에게 도움이되기를 바랍니다.

+0

시도해 보았지만 공개되지 않은 방법이 제대로 작동하지 않습니다. 원 대신 사각형이 풀리지 않습니다 ... –