Added activity transition animations.
This commit is contained in:
@@ -43,7 +43,8 @@
|
||||
android:supportsRtl="true">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name">
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.Main">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -53,7 +54,8 @@
|
||||
<activity
|
||||
android:name=".DetailActivity"
|
||||
android:label="@string/title_activity_detail"
|
||||
android:parentActivityName=".MainActivity" >
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:theme="@style/AppTheme.Details">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.example.android.sunshine.app.MainActivity" />
|
||||
|
||||
@@ -24,6 +24,8 @@ import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.ActivityOptionsCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
@@ -176,7 +178,10 @@ public class MainActivity extends AppCompatActivity implements ForecastFragment.
|
||||
} else {
|
||||
Intent intent = new Intent(this, DetailActivity.class)
|
||||
.setData(contentUri);
|
||||
startActivity(intent);
|
||||
|
||||
ActivityOptionsCompat activityOptions =
|
||||
ActivityOptionsCompat.makeSceneTransitionAnimation(this);
|
||||
ActivityCompat.startActivity(this, intent, activityOptions.toBundle());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:transitionOrdering="together"
|
||||
android:duration="500">
|
||||
<fade xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<targets>
|
||||
<target android:excludeId="@android:id/statusBarBackground"/>
|
||||
<target android:excludeId="@android:id/navigationBarBackground"/>
|
||||
</targets>
|
||||
</fade>
|
||||
<slide android:slideEdge="top">
|
||||
<targets>
|
||||
<target android:targetId="@id/toolbar" />
|
||||
</targets>
|
||||
</slide>
|
||||
<slide android:slideEdge="right">
|
||||
<targets>
|
||||
<target android:targetId="@id/detail_additional_pane" />
|
||||
</targets>
|
||||
</slide>
|
||||
|
||||
</transitionSet>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:transitionOrdering="together"
|
||||
android:duration="500">
|
||||
<fade>
|
||||
<targets>
|
||||
<target android:excludeId="@android:id/statusBarBackground" />
|
||||
<target android:excludeId="@android:id/navigationBarBackground" />
|
||||
</targets>
|
||||
</fade>
|
||||
<slide android:slideEdge="right">
|
||||
<targets>
|
||||
<target android:targetId="@id/detail_additional_pane" />
|
||||
</targets>
|
||||
</slide>
|
||||
</transitionSet>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:transitionOrdering="together"
|
||||
android:duration="500">
|
||||
<fade xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<targets>
|
||||
<target android:excludeId="@android:id/statusBarBackground"/>
|
||||
<target android:excludeId="@android:id/navigationBarBackground"/>
|
||||
</targets>
|
||||
</fade>
|
||||
<slide android:slideEdge="top">
|
||||
<targets>
|
||||
<target android:targetId="@id/toolbar" />
|
||||
</targets>
|
||||
</slide>
|
||||
<slide android:slideEdge="bottom">
|
||||
<targets>
|
||||
<target android:targetId="@id/detail_additional_pane" />
|
||||
</targets>
|
||||
</slide>
|
||||
|
||||
</transitionSet>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:transitionOrdering="together"
|
||||
android:duration="500">
|
||||
<fade>
|
||||
<targets>
|
||||
<target android:excludeId="@android:id/statusBarBackground" />
|
||||
<target android:excludeId="@android:id/navigationBarBackground" />
|
||||
</targets>
|
||||
</fade>
|
||||
<slide android:slideEdge="bottom">
|
||||
<targets>
|
||||
<target android:targetId="@id/detail_additional_pane" />
|
||||
</targets>
|
||||
</slide>
|
||||
</transitionSet>
|
||||
@@ -21,4 +21,14 @@
|
||||
<item name="android:colorPrimaryDark">@color/primary_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Main" parent="@style/AppTheme">
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Details" parent="@style/AppTheme">
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
<item name="android:windowEnterTransition">@transition/details_window_enter_transition</item>
|
||||
<item name="android:windowReturnTransition">@transition/details_window_return_transition</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -28,6 +28,10 @@
|
||||
<style name="SettingsTheme" parent="AppTheme">
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Main" parent="@style/AppTheme"/>
|
||||
|
||||
<style name="AppTheme.Details" parent="@style/AppTheme"/>
|
||||
|
||||
<!-- main activity toolbar style -->
|
||||
<style name="Toolbar" parent="Widget.AppCompat.Toolbar">
|
||||
<item name="android:background">?attr/colorPrimary</item>
|
||||
|
||||
Reference in New Issue
Block a user