Android Studio & Constraint Layout Editor Problems - android

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

Related

Activities overlapping

I am new to writing Android apps, I have been using the internet and Android Studio to create an app for my club as a bit of fun and learn along the way. I have been watching videos, using tutorials and walkthroughs and I am getting to learn the basics.
However, I have got stuck. I used a drawer template from Android Studio and added the activities I needed and buttons on the main screen to the activities and they all worked fine, no overlapping. When I tried to link the drawer icons to the activities, rather than use the buttons on the main screen, they work, but the app (visually) puts the next activities content on top of the one before.
I cant find anything on the internet except something called backstacking, but that is described when the back arrow is used, my problem is to do with selecting an activity from the drawer menu. I have attached a picture to show what I mean. It gets worse the more menu items that are selected.
If anyone could help, it would be great!
If you are using XML root layout as a constraint layout maybe your constraints are missing. If you are using constraint layout set both top/bottom and left/right constraint.
If your constraints only top for example it is look good on desing but in device that dont know where to positioning left or right and automatically positioning 0 point to top.
When you click one any one menu item put the visibility of other images as gone like
visibility(View.GONE);
and the one selected to be visible

Android Studio 3 Layout Editor Weird Behavior

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.

Android Studio 2.2 Gridlayout not working

I can understand maybe Android Studio 2.2 is different but I feel like it's not working at all with GridLayout, I'm watching thenewboston tutorial 17 for GridLayout, and when he makes it wrap around content then drag the buttons into it, it shows a bit of information over the mouse about where the button is going to be placed (Then shows green bars to indicate where the button is), mine doesn't do that and also it doesn't work at all. I'll include a gif of what I'm talking about.
Also, how do you enable the tooltips for the palette? and no I'm not talking about the quick docs but the mouse hover tip over the palette items.
Here is a gif https://gyazo.com/8a2bc1919f3d117238b7f52be11a2316
And also the error codes that pop up, one of them says view requires API Level 14 (Current min 9):<.GridLayout/>
And the other says
This Gridlayout view is useless (no children, no background, no id, no style)
Regarding dropping the button on the Grid... just drop the button on the GridLayout on the component tree (bottom left). Once you have the first item there you can use the grid as you'd normally expect it to work by moving the buttons around.
I realize that this question is a tad old, but also that it comes up quickly in a google search, so I hope that my solution can be of help to some one.
I was going through this same tutorial, and while I was never able to figure out if it's possible to enable the green lines or drag and drop properly into a GridLayout, I did find how to do it explicitly in the XML file.
In the tag for your button, simply add:
android:layout_row="X"
android:layout_column="X"
where x is any (positive) integer number from top to bottom for the row value, and left to right for the column value.
A less than ideal solution I know, but hopefully some one will benefit from this.

DISABLE the auto arrange of widgets in eclipse

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.

Android: Have an arbitrary View slide under another View like the software keyboard does

I want to have a View pop in at the bottom of the page exactly like
the software keyboard view does in the compose section of the Mms app.
It slides in from the bottom, as if it's being added to a vertically
oriented LinearLayout, only making the ListView smaller. It becomes a
part of the current layout instead of popping up over the top of it.
I'd like to to this exact thing with my own custom View.
Does the question make sense at all?
Sure it makes sense!
I have a SlidingPanel demo that demonstrates the general technique. It's a bit more complicated than it needs to be, since it implements a custom View class.
The gist is you actually have your panel in the layout to begin with, positioned where you want it to be, but you set android:visibility="gone" so it doesn't appear. When you want it visible, make it visible and set up a TranslateAnimation to slide it in.
Today there is a SlidingLayout view to use as explianed in this question.
Just use this lib and add the following in your layout:
<com.wunderlist.slidinglayer.SlidingLayer
xmlns:slidingLayer="http://schemas.android.com/apk/res-auto"
android:id="#+id/slidingLayer1"
android:layout_width="#dimen/layer_width"
android:layout_height="#dimen/layer_height"
slidingLayer:shadowDrawable="#drawable/sidebar_shadow"
slidingLayer:shadowSize="#dimen/shadow_size"
slidingLayer:offsetDistance="#dimen/offset_distance"
slidingLayer:previewOffsetDistance="#dimen/preview_offset_distance"
slidingLayer:stickTo="top|bottom|right|left"
slidingLayer:changeStateOnTap="true">
and add the following to your gradle build file:
compile 'com.wunderlist:sliding-layer:1.2.5'
You can download a demo app from here

Categories

Resources