Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBoban Talevski
24,793 PointsHelp with the exercise mentioned near the end of the video about activity transitions in XML
Can we get a bit more help with the exercise mentioned near the end of the video (at about 4:30)?
Namely, we did set up the basics of Activity Transitions in the styles-v21 file by adding this item in the themes
<item name="android:windowEnterTransition">@android:transition/slide_right</item>
So this means that all activities in the app will slide from the right, which is ok (5.0 or greater). But how do we add more specific details about the activity transitions in XML?
And what if we want to have different transitions for different activities. Do we create specific themes per activity with respective transitions and apply that theme to each activity in the manifest?
This seems to be an important topic as I don't see myself using activity transitions in code anytime soon (assuming we want our apps to be backwards compatible at least to 4.4 or so), so we should use the XML option more often I guess. Thus, we could use some basic pointers/examples or maybe even an additional video added in this course at the end of this section giving some basic examples about activity transitions in XML so we at least know where to start when delving deeper in the subject.
1 Answer
Ryan Jones
1,378 PointsIn themes in v21/styles.xml, I changed from slide_right to slide_bottom and set windowSharedElementsUseOverlay to false. This matches what Ben had done in Java code.
<item name="android:windowEnterTransition">@transition/slide_bottom</item>
<item name="android:windowSharedElementsUseOverlay">false</item>
I added my own slide_bottom transition under the res/transition folder in v21/slide_bottom.xml. It specifically excludes the status bar from the transition animation, also to match what Ben had done in Java code:
<?xml version="1.0" encoding="utf-8"?>
<slide
xmlns:android="http://schemas.android.com/apk/res/android"
android:slideEdge="bottom">
<targets>
<target android:excludeId="@android:id/statusBarBackground" />
</targets>
</slide>
Zach K
6,356 PointsThank you! This helped me understand how the Java transition gets translated into XML and vice-versa.
Varun Dixit
570 PointsVarun Dixit
570 PointsHello, Ben Jakuben Sir, please take a look at the question it seems important to me.