Skip to content

Instantly share code, notes, and snippets.

@bhurling
Last active August 29, 2015 14:08
Show Gist options
  • Save bhurling/2449201630016856b19a to your computer and use it in GitHub Desktop.
Save bhurling/2449201630016856b19a to your computer and use it in GitHub Desktop.
Weird activity transition hickup.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#0000ff" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#00ff00" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#0000ff" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#00ff00" />
</LinearLayout>
<View
android:id="@+id/view"
android:layout_width="56dp"
android:layout_height="56dp"
android:background="#ff0000"
android:elevation="8dp"
android:transitionName="view" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/view"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#ff0000"
android:elevation="8dp"
android:transitionName="view" />
</RelativeLayout>
public class MainActivity extends Activity implements View.OnClickListener {
View mView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mView = findViewById(R.id.view);
mView.setOnClickListener(this);
}
@Override
public void onClick(View view) {
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, mView, "view");
Intent intent = new Intent(this, SecondaryActivity.class);
startActivity(intent, options.toBundle());
}
}
<?xml version="1.0" encoding="utf-8"?>
<slide />
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- enable window content transitions -->
<item name="android:windowContentTransitions">true</item>
<!-- specify exit transition -->
<item name="android:windowExitTransition">@transition/slide</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment