Android Studio reorders view elements in layout xml when formatting - android-studio

I clean installed Android Studio, currently running Build #AI-213.7172.25.2113.9014738, built on August 31, 2022. Inside layout XMLs When hitting CTRL+ALT+L to format, or also when having the format-option checked in the commit-prompt before committing my changes to git, the IDE will reorder the View elements in my XMLs.
Since the order of View elements determines which View is drawn on top of the others, this causes issues. How do i disable this behaviour? I looked at the CodeStyle settings for XMLs but couldn't find any settings for this specific behaviour.

Under Settings -> Editor -> Code Style -> XML there is the option "Set from..." on the top right corner. If that isn't set to "Android", this could be the problem.

Related

After upgrading to Android Studio 4.1 why doesn't the text in my CheckBox controls display in runtime (but does display in design mode)?

Here's a snapshot of my app where you can see the running app which has missing text and you can see the text that should be displaying (which is properly displaying in design mode).
Why isn't the text displaying at runtime?
This only started happening when I updated to version 4.1 of Android Studio and rebuilt my app.
Additionally, here is how they are defined in the layout xml:
Here's a view of the layout details of the one checkbox that is not displaying the text:
Notice that it is showing text size in PT (points).
I changed it to sp after choosing from droplist and now it displays properly.
Not sure why this has always worked in the past and suddenly stopped working.
If it is a change I would expect an auto-update functionality when Android Studio upgrades the project.
Should Not Work In Design Mode Either
If it is a problem I would also expect it to display improperly in the Design Mode also. Instead it looks correct in design mode even though runtime doesn't display it. In this way I would've understood that I was using an incorrect unit.
TextView Also
I found that this was also happening in many of my TextView controls.

Android Studio: Component is selected but Attributes editor says "No component selected"

TL;DR: Although I can edit component attributes directly in XML (sanity check — I'm sane) the Attributes inspector pane claims nothing is selected. I.e. "It doesn't work."
I added a CardView to the main layout. It does show up in the Component Tree and in the Design Editor. I select the CardView in the Component Tree pane, but the Attributes pane says "No component selected".
I'm using Android Studio 3.5.2 on MacOS 10.15.1. This happens with all three CardViews (see screenshot).
Clicking the Text tab shows the XML for all the components, including the (so-called) "non-selected" one. Direct edits I make on the CardView XML entity do have effect, and the app builds and runs correctly, with all three CardViews showing up and scrolling in the ScrollView. So this is probably not a gradle issue (thanks autocorrect, it's not a cradle problem either). It's more like the build process knows about the views, but not the edit process.
I re-created the project from scratch, with the same result.
I had the same problem today with a FloatingActionButton in Android Studio on macOS.
Restarting Android Studio was the solution for me.

Android Studio - view both Text and Design preview of layout

In Android Studio, how can I view both the text and design preview of an XML layout side by side.
I could see it by default when I installed Studio, but now that is gone,
and I'm not sure why. I can only see or the other.
How do I re-enable it?
Open your [whatever].xml. At the bottom you'll see Design and Text. Select Text. If you still can't see the actual layout, only xml, then select "Preview" which is located at the right of the window, between Gradle and Maven Projects.
Click on preview while text is selected.
At first, select your desired .xml layout from the Project tab then use Code, Split and Design buttons to switch between the views. (Android Studio 3.6)
Code - Display only XML part
Split- Display XML and design both
Design- Only design part
It appears that in Android 3.6.1, the buttons to select Design, Split, or Code have been placed in the upper right of the XML layout screen.
Select any one from the top right options to change the view of your Code and Design
You can split the tab by right-clicking on the tab and selecting either Split Horizontally or Split Vertically. Then, you can select the Design tab on one and the Text tab on the other.

Switching TabHost Tabs in Android Studio UI Designer

How can I switch between the tabs of a TabHost in the UI Designer for inserting content? Is there a keyboard shortcut or something else
I found a way to visualise any tab using TabHost in the UI Designer. Is probably not the best way, but it works.
1. Go to the Component Tree, where you have all the elements of the UI.
2. Inside the FrameLayout that TabHost automatically creates for you, there are the tabs.
3. If you change the order of the tabs just drag and dropping in the Component Tree, you get to see the one that is placed in the first position.
UPDATE:
According to this answer there is no way to change the tabs of a TabHost. That question refers to IntelliJ; I don't know if it applies to Android Studio.
Also, it seems that TabHost has been replaced by FragmentActivity and ActionBar. See Android how can i replace the deprecated tabhost? for a discussion.
It is defined as "Select next Tab in multi-editor file" in Settings -> Keymap.
On Windows it seems to default to CRTL+SHIFT+RIGHT/LEFT or ALT+SHIFT+RIGHT/LEFT. On my Mac it defaults to CTRL+SHIFT+RIGHT/LEFT.
Note that Studio doesn't allow the default Keymap to be edited so you will first need to copy the default and give it a new name.
Also see Shortcut to switch between design and text in android studio.
By mouse, select the FrameLayout then long left click on any space in it.

How to set permanent Zoom factor in Visual Studio Editor 2012 tabs

If I set the zoom of a tab to 120%, then when opening new tabs, Visual Studio 2012 should open them with a 120% zoom factor and not 100% (the default).
But when reopening, Visual Studio the Zoom Percentage should be preserved (120%).
Is there is any way to solve the issue?
If you are simply zooming so the text in your editor is bigger, then why not just increase the font size?
Open TOOLS -> OPTIONS, under the 'Environment' tab select 'Fonts and Colors', and change the font size to whatever you want.
--edit--
As #Anovative pointed out in his comment and answer below, there is now a way to set default zoom within Visual Studio 2013 (and subsequent versions I'd assume).
Go to Tools > Extensions and Updates > then get the extension
VSCommands for Visual Studio 2013 ...if you're using VS2013
Then Tools > VSCommands12 > General > click the button Open Configuration.
Then close out of the Options window and in the VSC - Config tab that should be open go to the Zoom option and set your default zoom level. This will apply to all editor tabs. You can still zoom in or out of individual tabs as desired. But your default zoom will be preserved even after closing VS and will be restored upon starting VS.
This extension solve the problem
http://visualstudiogallery.msdn.microsoft.com/71870f0e-87bb-4a5f-8abd-e8e5e0ccb900
These tools do not solve the whole problem, but may help:
http://visualstudiogallery.msdn.microsoft.com/71870f0e-87bb-4a5f-8abd-e8e5e0ccb900?SRC=VSIDE
http://visualstudiogallery.msdn.microsoft.com/6a7a0b57-7059-470d-bcfa-60ceb78dc752/
Maybe this also helps:
Visual Studio 2010 default zoom level
Considering this Default Zoom question, the whole problem is not solvable (for VS up to 2010) :-/. From my point of view this is a really missing feature.
Edit: Solve the Post from Aditya Patil the problem?

Resources