Closed AlexandruDev closed 7 years ago
It works just fine on 5.0+ devices, but on pre-lollipop I don't see the reveal animation.
activity_details.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="250dp" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:layout_scrollFlags="scroll|enterAlways|snap"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:titleEnabled="false"> <io.codetail.widget.RevealFrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/backdrop" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="center"/> </io.codetail.widget.RevealFrameLayout> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="pin" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <include layout="@layout/content_detail" /> </android.support.design.widget.CoordinatorLayout>
DetailsActivity.java
public class DetailsActivity extends AppCompatActivity { private TextView t1; private ImageView imageView1; @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_details); t1 = (TextView) findViewById(R.id.textview_1); t1.setText(R.string.text_1); imageView1 = (ImageView) findViewById(R.id.backdrop); Glide.with(this) .load("some url") .error(R.drawable.error_glide) .priority(Priority.HIGH) .centerCrop() .crossFade() .into(imageView1); beginEnterTransition(); } private void beginEnterTransition() { imageView1.post(new Runnable() { @Override public void run() { // get the center for the clipping circle int cx = (imageView1.getLeft() + imageView1.getRight()) / 2; int cy = (imageView1.getTop() + imageView1.getBottom()) / 2; // get the final radius for the clipping circle int dx = Math.max(cx, imageView1.getWidth() - cx); int dy = Math.max(cy, imageView1.getHeight() - cy); float finalRadius = (float) Math.hypot(dx, dy); // Android native animator animator = io.codetail.animation.ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.setDuration(800); animator.start(); t1.startAnimation(AnimationUtils.loadAnimation(DetailsActivity.this, R.anim.fadein)); } }); } }
Got it, have to check it out
Solved! I had to remove this line android:scaleType="center" from ImageView.
android:scaleType="center"
ImageView
Any idea why that line was preventing the animation from showing?
No idea =(
It works just fine on 5.0+ devices, but on pre-lollipop I don't see the reveal animation.
activity_details.xml
DetailsActivity.java