So in my nav_graph.xml file, I have a lot of fragments. It took quite a while for me to drag them around in the Design view, and I want to make sure that is backed up. I'd like to track that in my git repository, but I have no idea where that information is stored.
I'm assuming it is in a file somewhere. Does anyone know where that file lives and what the name of it is?
EDIT
To be clear: I am not looking for the xml file itself. I know where that is. It's over 800 lines long, so if I didn't know where that was, it would be magic that I even had a nav graph at all.
I'm looking for the file (or wherever the information is stored) that controls how it is laid out visually in the designer. That the view where you can drag the fragment tiles around to present the graph visually.
For example, this from the Android docs:
What if the green tile was dragged above the pink/orange tile? Something has to save those coordinates, right? Or it wouldn't load again the next time I started Android Studio. Where is that information saved??
nav_graph itself saves all the information, related to the fragment directions and actions, which actually defines all the required information for working of the Navigation graph.
I'm looking for the file (or wherever the information is stored) that controls how it is laid out visually in the designer.
Information regarding the visual representation of the nav graph is editor specific, and Android Studio stores it in .idea > navEditor.xml.
To access .idea directory, you've to be in project mode.
The information is stored in nav_graph.xml itself. For designing layouts, menus and working with Nav graphs, Android Studio provides the functionality of either writing it as a code or design it, while the code will be written internally by the IDE.
In the above picture, you have been using Design tab to place the fragments, while on the other hand, you can check the Code tab, where it is written in plain XML
app > res > navigation > your_nav.xml
Related
I've an application that uses Fragmnent Views with XML resources and I want to migrate it to Compose. Being the app quite big, I decided to temporarily have a mixed environment with Compose working together with the old XML resources, so I created a new Compose fragment and I succeeded to add the standard navigation action to navigate to it. The code builds successfully, but when I try to run the app I get the error of the picture below. It is particularly wierd because this error appears immediately, and not in the build panel, but in a popup dialog. Any hint ?
Ok, the documentation is not very clear, but in the end I found this:
"You can also include a ComposeView directly in a fragment if your full screen is built with Compose, which lets you avoid using an XML layout file entirely."
Being my app a hybrid one with XML navigation graphs, it looks like I need to define an XML resource anyway.
I hoped I cound avoid defining an XML layout, but it seems I need one for a fragment that has an old fashioned Activity as parent.
I'll post an update as soon as I discover something new
UPDATE
Adding an XML layout didn't fix the problem.
In fact the XML layout is not necessary. I don't really understand the cause of that error, but after cleaning a couple of times the project and clearing A.S. cache it disappeared. I succeeded to add a Compose Fragment to an old XML resources style app. The old navigation works without problems. Hope this post will help someone else save the time I have wasted...
I have searched everywhere for an answer to the problem below without success.
I understand that there are two ways of visually connecting fragments during navigation: namely animations and transitions.
I have understood and used animations to connect two fragments but now I want to use the set transitions, not animations.
Here is the problem: I have two fragments, when the current fragment is replaced I want the second one to slide in - I suspect that using a built-in transition is simpler than an animation.
I get stuck at this point in the android developer's guide - only a code snippets are shown - what would the full xml resource file look like ?
All insights welcome
Solved. Just required a calm and close re-study of the Android Developer's guide on the 'Transitions Framework' and also The classes Fragment, Transition, TransitionManager, Fade, Slide.
My initial panic was caused by Android Studio opening a new xml file from the transition directory with an auto-template that began with the root tag <transitionManager> but files in the res/transition directory can begin with roots <transitionManager>,<transitionSet>, <transition> or simply the name of one of the built-in transitions such as <slide> with the parameters of the slide as attributes.
I'm not sure if it's something I'm doing or not, but the scenario is this....
When I create multiple layout-* (i.e. layout, layout-ldpi, layout-xhpdi, etc) folders and place the AXML files in each of the folders.... double click to open them in the designer... it DOES change the "device" selection for the display correctly, BUT the actual visual display DOESN'T change.... making it VERY difficult to see how multiple screens are going to handle the layout files (i.e, no matter the selection I make on the layout nodes on the left).
I know in older Xamarin Studio versions it did update the layouts where I could make the necessary changes, but not any more.
Im not sure if it's some setting, or something I'm missing, but I need it to work. :)
If anyone can lead me in the correct direction to fix this it would be awesome!
To my understanding, the content file is just the xml files contents...but in a separate file. Whats the point?
I've seen
What is the role of content_main.xml in android studio 1.4?
and there doesn't seem to be much documentation about content_XXX.xml, so I was wondering, why did the new update include the default creation of this file?
Why divide the code into two files, why not just put all of the contents in its own xml file, I've tried it...and it works. I fail to understand why the content_main file is generated on creation of a new project.
Can someone give me a list of benefits of why I should be using the content file?
Thanks,
Ruchir
activity_main.xml is used to display coordinatorLayout, tabLayout, floatingActionButton, viewPager etc.
content_main.xml is used to display your stuff i.e. what you want to display to users.
for more details check my answer here.
Update after conversation in comments below: The point of doing this is to bring in more organization in the code. We can always go forward with the old way of putting everything in one file. Android Studio is just giving us a start with keeping the layouts in a more organized way to allow easy comprehension of code and reuse wherever possible, by segregating related stuff.
Working with Android for the first time, I've blocked out a layout using the relative layout and laid down some buttons and text widgets how I like them. However when I go back to rename the IDs the layout goes all crazy moving elements around and in general destroying the hours of work I spent laying them out.
Does anyone know how I can rename the widgets without Android destroying the positioning for widgets in the Relative Layout? Is this some "feature" of Android? I can't imagine why it would be hard for the UI builder to handle simple renaming of a widget ID without destroying the positioning information.. Do I have to use an external text editor and modify the XML files directly? Ughh I hope not.. I'm using Eclipse IDE.
You can use find and then replace all to change the names every place that they appear. Shouldn't take anywhere near an hour if you're dealing with a small layout.
In general the graphical UI creator that is currently included with the Android SDK is not so great for creating anything but very simple layouts. In my experiences (which were a long time ago, it may have gotten better since) it was terrible with RelativeLayouts.
If you have not modified your xml directly then it is time that you jump in and start learning to do it that way. You'll find that you have a much greater level of control over your layout, and once you get the basics figured out you'll probably be able to create quicker using raw xml then with the graphical tool anyway. I do wish that there were a nice GUI creator for android out there, the best one that I've ever come across is Droid Draw which I found to be better than the one included with the SDK, but still not as good as I was hoping.
To modify the xml directly you don't need any additional text editors, you do it inside eclipse. Open up your layout file and at the bottom click on the tab that says "Source" when you want to switch back to graphical (good to see the changes that you make to the xml graphically) just click back to the tab that says "Design"