After the update to 2.2 the designer seems to gone crazy.
I using API 24 with Build Tools Version 24.0.3.
Into the designer if i have a parent GridLayout or the v7:
I can't drag the first subview inside. The only solution i found is that to drag it into the Component Tree.
If i add two subviews, i can't arrange them by dragging inside the designer, before the 2.2 version of android studio the columns and the rows was , now it shows this error and stops to respond:
java.lang.NullPointerException
at com.android.tools.idea.uibuilder.handlers.grid.GridDragHandler.commit(GridDragHandler.java:56)
at com.android.tools.idea.uibuilder.surface.DragDropInteraction$1.run(DragDropInteraction.java:191)
at com.intellij.openapi.application.RunResult.run(RunResult.java:35)
at com.intellij.openapi.command.WriteCommandAction$2.run(WriteCommandAction.java:108)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:99)
at com.intellij.openapi.command.WriteCommandAction.performWriteCommandAction(WriteCommandAction.java:103)
at com.intellij.openapi.command.WriteCommandAction.access$000(WriteCommandAction.java:34)
at com.intellij.openapi.command.WriteCommandAction$1.run(WriteCommandAction.java:85)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:723)
at com.intellij.openapi.command.WriteCommandAction.execute(WriteCommandAction.java:82)
at com.android.tools.idea.uibuilder.surface.DragDropInteraction.moveTo(DragDropInteraction.java:203)
at com.android.tools.idea.uibuilder.surface.DragDropInteraction.end(DragDropInteraction.java:123)
...
Sometimes into the designer if i click one subview of the GridLayout it goes at the bottom of the superview, in xml preview too!!!
Now the designer doesn't allow me to copy components between 2 different layouts ( i have to copy it from xml ).
If a property of a view is selected into the right panel ( for example : text for a TextView ) and i press delete, it deletes the components instead of resetting the property ( i have to delete the line from xml ).
It should be the stable version, but in my opinion, it's not usable like before, now i have to manually modify the xml more then before.
I already tried to clear all like: Described here and then reinstall it. But it's the same.
It's something that i am missing?
Related
This question is about Xamarin Android which supports drag and drop functionality, not Xamarin Forms.
When using the Xamarin Android Designer in Visual Studio I am only allowed to drag in one control from the toolbox. After this, I am no longer able to add any new buttons (with the cursor changing to a "not allowed" symbol when trying to drag in a new button).
Steps to reproduce the problem:
Create a new Xamarin Android App project in Visual Studio.
Navigate to the "Resources/layout/activity_main.axml".
Try to add two buttons to the Design. Trying to add the second one will show the "not allowed" symbol in place of the cursor.
I've looked online for a solution, including Xamarin Community Forums and the Visual Studio Developer Community and but have only found posts on the same or similar issue with no solution that has worked for me. How can I solve this?
RelativeLayout in Xaml doesn't allow drag&droping more than 1 control by design.
RelativeLayout is a ViewGroup that displays child View elements in relative positions. The position of a View can be specified as relative to sibling elements (such as to the left-of or below a given element) or in positions relative to the RelativeLayout area (such as aligned to the bottom, left of center).
Basically, designer let you add only one control on which you design your interface. You position the other controls from Xaml based on original dragged control.
You can drag&drop controls from toolbox directly to Xml code and it allows you to edit further the control from Properties box.
Also, https://developer.android.com/guide/topics/ui/layout/relative officially recommends to use ConstraintLayout instead.
If you insists to use RelativeLayout, you will have to code the interface in Xaml.
I just downloaded Android Studio and decided to try it out, never programmed in Java, or any kind of android app. It all seems good but once I emulated the app. I got weird formatting that wasn't a thing in app preview when I coded it. This is a simple "squaring" function app.
When I look at the preview:
When I emulate it:
You are getting this kind of formatting because you are using Constraint Layout as your root layout. There are no constraints to the views(EditText, Button and others) because of which they are placed at the top left corner of the screen.You have to add constraints in ContraintLayout.
Follow any of the three methods below-
Learn about Constraint Layout. Check out this link -Build a Responsive UI with ConstraintLayout in Android Studio (Most Useful of the three)
Change Constraint Layout to Linear Layout or Relative Layout as your root layout.(if you are familiar with them)
Click Infer Constraints (orange color two stars type symbol ) to automatically create constraints and compile again.(Simplest of the 3 methods for you right now)
I'm using android.support.constraint.ConstraintLayout to layout a simple card's content views.
I'm getting random changes in my XML, every time, when:
I switch to Android Studio's layout editor's Design tab
Or when I have a Preview pane turned on (in this case changes happens even more often during my changes).
Those random changes include:
Removal of my manually defined layout margins (eg. layout_marginEnd)
Changing values of my manually entered margin value
Adding tools:layout_editor_absoluteX values
Questions:
Anyone else experience this Android Studio's feature?
How to switch this "feature" off, so my layouts would not be destroyed?
Where to report this bug to Google or JetBrains?
Please take a look to this file diff, which was made automatically when switched to Design tab:
PS.: My Android Studio version is 2.2.3; I'm running it on macOS Sierra.
Update #1
As suggested, after making layout_height="match_parent", I get modifications less often, but still my XML gets messed-up, when I edit layout in Layout Design'er:
This time I wanted to set layout_marginTop through Design UI (selected line is what I wanted to add), but I also got those other unwanted changes:
layout_marginStart removed;
app:layout_constraintBottom_toBottomOf referenced IDs got a prefix of "+" sign, which means, those IDs are newly declared, so when I'll use Goto declaration functionality, I'll have to choose it from the list - not a desired behaviour.
tools:layout_editor_absoluteX gets added. I could ignore it, but still - not what I'd want to happen.
In my case removing the layout constraint and adding it again fixed the disappearing margins.
I'm on Android Studio 4.1.1.
I have been noticing the same issue with Android Studio 2.3, the code changed automatically every time I went from text view to design view on a recent project with ConstraintLayout. - I'm pretty sure it happens with RelativeLayout or whatever other layout you want to use as well.
I guess it is some type of auto code generation bug linked to the design view, I have not been able to find a way to turn it off yet.
I'm not sure this helps because I'm confident you've already realized it, but if you work almost completely in text view, the issue never happens.
I occasionally use design view to begin my layout but once I have something working, staying in text view personally seems to be faster for the development process.
As #JoeyJubb mentioned, using layout_height="match_parent" solves this problem. At least XML is not modified. Although, sometimes preview is generated incorrectly.
In my case upgrade to newest gradle dependecy helped:
com.android.support.constraint:constraint-layout:1.0.2
Also I started using 0dp instead of match_parent for layout_width
I had to edit the Constraint Layout XML file by hand (*), so I also removed all the tools: fields from the XML. To my understanding these attributes are only used by Android Studio and the Constraint Layout tool. But I removed them because I wanted to reset the state of the layout and changing the android: properties for the Constraint Layout surely would only mix things up even more, right?
So I am now in a situation where the blueprint view stays empty and the hierarchy view says "Nothing to show". I see no view properties and no constraints. I can only see the flat UI design view of the layout, but I can't select any elements from it either.
Any ideas how to fix this?
I am running Android Studio 2.2.3 and Constraint Layout beta 4.
*) Why did I edit the layout by hand you ask? Well, I selected "Convert to Constraint Layout" in which case Android Studio just flattened my layout and hard coded the positions of all elements. Which wasn't exactly what I wanted since then I couldn't change the positions anymore. Removing the hard coded positions (and the tools: arguments) let me re-structure my layout.
Ok, I am going to answer this myself since I got it working thanks to Nicolas Roard who works on the Constraint Layout team at Google.
try pressing "r" [in the design view]
https://twitter.com/camaelon/status/809427379500126208
I wasn't aware of the keyboard shortcut "r" in this case, but it did solve it for me!
I have android studio. But when using the ScrollView to design the layout and etc in inside the screen, I have a problem and when I want to add the additional tools greater than the screen, I can not do this action.Also I have the android studio old version.
You need to edit the xml of the view that you want to Put it out of the screen. For example to put it outside the right bound. Simply add
android:layout_marginRight="-250dp"