I am working on an Activity using a constraint layout. Every once in a while, when I try to increase the margins on one of my views, the changes seem to be ignored. I change the margin in the android studio ui, and the change briefly takes effect, but when I move focus to somewhere else on the activity, it shrinks back to the old distance, while keeping the new number. The change appears in the xml layout, but when run in the emulator, it doesn't render. This can usually be fixed by deleting and recreating the view.
Does anyone know why this happens or how to fix it?
I'm not sure if this will answer your question, but if you have two layout margin attributes of the same direction, like layout_marginLeft and layout_marginStart, sometimes the changes in the design tab only changes one of them, and it defaults to the other, so you have to change both manually in the xml file.
Related
I have watched numerous videos, including Google's own, and i'm really struggling with ConstraintLayout, it simply doesn't work for me, like it works in the online videos.
When I drop a textview onto the constraint layout editor, it jumps to the top right of the form. In the demo videos, it stays where it's dropped, and it's easy for those people to set up the relationships by dragging handles. For me, It's all up in the top right, and I can only get to 2 of the handles.
It gets worse if I then drop two more text views into the form, they are all now all the same size and all overlapped at the top. Whenever I use constraint layout, I end up tearing my hair out, and then giving up and going back to an older layout.
I really want to use constraintlayout, but clearly I am missing something really obvious here, but I can't figure out what.
Yes the drag and drop doesn't work well. For me I just use several steps to add a new view:
1. drag new view to the end of the view list window (not on the design view! design view will add unnecessary properties and is not clean)
2. select the new view, and name it! name is very important to constraint layout.
3. set the layout_constraint_xxx attributes from the property window
then it goes to the expected places.
Try disabling the experimental render engine and re enable it again
I am posting and answering my own question because this issue took me days and days to figure out, and finally I did some half-baked kludge, and then months later I found the actual answer, and I want to spare others that.
Problem: to get iOS text entry elements to scroll up and stay visible when a keyboard appears, in Xamarin Forms the easiest way is to use a ScrollView, BUT for some reason any time you use a ScrollView the dang thing resizes its content so that some of it is slightly off screen.
Content not inside ScrollView:
Content inside ScrollView:
As you can see, for some darn reason the ScrollView has its own opinion about how to lay out its contents, and that opinion is that some of it should always be off-screen.
What the heck? I've tried changing layouts and using different kinds of nesting views and adjusting layout options and margins and everything I could think of. The dang layout just always changes without me telling it to!
How do I make it behave?
ScrollView has an Orientation setting to determine the directions it can scroll. You can set it to Neither right there in the XAML, and all your content will be back where it should be.
Note that if you actually want scrolling behavior, this will mess that up. But if you're only using a ScrollView to get its nice behavior around keyboards appearing and disappearing, as I usually am, that shouldn't matter.
In order to make things clean for you to understand i recorded a video
The problem is that when i'm adding a Tab Layout inside another layout everything that appears in the blueprint becomes a dot in the upper left corner, leaving me with no other choice but to edit the xml itself in order to create the UI. This also happens sometimes when I add multiple nested layouts.
I'm searching like a week until now but still i can't understand why is this happening.
My question is, is there a way to get a certain view element to ignore the windowSoftInput setting, or to set a specific setting for one view element? (Any other solutions to my problem are also welcome)
Below are more details about my problem.
I have an Android activity with a background image set to the main FrameLayout. This layout contains a few other layouts, among others a brand logo on one side, and a scrollview with edittext boxes on the other side.
Using the windowSoftInput="adjustResize" works pretty well, but it distorts the background image. Using windowSoftInput="adjustPan" however pans the brand logo out of the screen and messes with the scrollview, and the keyboard blocks the edittext boxes.
So far, looking around the web and the docs I can't find a solution, or if this is even possible. Android layouts always seem to confuse me though..
I'm fairly new to android programming (making the switch from Windows programming to Mobile Platforms.)
Problem: Every time I add, let's say, a text view, I get a green box around it that will put it in a location. When I add multiple text views, I go to place it down under another text view and everything in my app shifts, and moves everything into a stack on the upper left most part of the screen. It seems like every time I move one thing, 5 other things move with it.
Question: Is there a way to disable that function?
Go to your layout, right click it, then click on change layout. I changed it to absolute layout so I can move any or my widgets around the screen as much as I wanted without the movement effecting other widgets. Hope this helps
Android forces you to develop without a pixel-rigid notation. Basicly you have a set of Layout types (Linear, Relative, etc) that stablish a relation between the child's elements.
Therefore, it is important to know those Layouts, how can you connect them and how their childs are arranged.
In eclipse you can add elements but some things eclipse doesn't know how they are related. Eclipse will update the new data, and therefore moving all kind of views out of the way to update into the new hierarquy you defined. Therefore you can't remove "auto-layout". Even if you change to Absolute Layout (like David suggested) you are not removing the "auto-layout" feature. You are simply telling eclipse that you want to arrange your things with absolute positioning. However, absolute positioning is not advisable since you have several devices with different resolutions.
I advice you to read some information about Layouts and then try to use the XML. Don't be afraid. It can become quite easly. Actually, I prefer XML to interface builder in eclipse. After you get some idea how layouts work you can use make a better use of the interface builder.