What's the meaning of this line beneath inflated view variables? - android

I have recently updated Android Studio to 2.1.2, and also enabled Java8. But since then, there's a line beneath all of inflated view variables like this:
There's no explanation whatsoever.
Since I'm usually obsessed to eliminate all the warnings, these bother me that I can't do anything.

Related

Problem migrating to Jetpack Compose. Trying to run the app from within Android Studio generates a wierd error

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...

android studio issue: complex Layout is not showing in design view but just as XML

I have a somewhat complex layout.xml file (353 xml lines, 16kb) with multiple nested constraint layouts. This particular xml file is only showing a blank white screen in the design tab but works well when I run it on device and emulator. I have other smaller layout files which show the design normally on android studio but it seems that there is a bug with viewing larger xml files.
Is this a known issue? I tried refreshing layout and removing android studio cache but nothing seems to work. any ideas?
I do not think it has anything to do with the code since it runs normally on device and I am not sure posting the whole xml file on SO is a good idea.
update
What I realised is that all the elements in the layout seem to be 'invisible' at the top left corner since when I hover over them the pointer turns into a hand and when I click , certain elements get highlighted in the component tree. This is a screenshot of what I am seeing:
I added android:visibility="gone" which is vital to my app. Little did I know that it also applies to the design view which I find to be really useless. I want the visibility to be gone during runtime, not on a platform where I am supposed to be tweaking the design of the UI. This is ridiculous to me.
Does anyone know If I can keep visibility="gone" but still see the design in the design view of the layout?
You can use tools:visibility="visible" for designing purposes.
It has zero effect on the view in real use.
Don't forget to keep your android:visibility="gone".
In general, use tools attributes whenever you'd like to manipulate a preview in the designer while keeping your view attributes valid for real use.
Edit:
Keep in mind that there is a huge difference between invisible and gone. More about that

Why Android Studio is removing and/or changing layout_margin* constraints?

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

Blueprint view nor the constraints are now visible in Android Studio design view

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!

Android layout render without compiling

I'm new to developing with Android, and the biggest new thing is the way the UI is rendered (relative to other views instead of absolute locations and sizes). As a result, I've been experimenting a lot with layouts, and find myself changing 1 view or even just 1 property of a view, then having to recompile and launch it back into the emulator to see the result. Is there a tool that quickly (or at least quicker) shows what a UI looks like give a layout xml file?
You can look at http://www.droiddraw.org/ but it is not perfect.
You can use Eclipse with Android Development Tools, when opening a layout file you get a preview of what looks like. Besides, ADT provides some nice features for developing and debugging in the Android platform.
When you're in the XML view, simply click the "Layout" tab on the bottom, and you'll be taken to a visual representation of your layout:
Like so:
There are some limitations for sure (e.g. text shadowing, for one, will not be depicted in this view), but it's a good way to get a general idea of how your layout is working.
Versions 2.x and higher of Android Studio render the XML in real-time in the Preview pane of the IDE and it even juxtaposes the XML and outline views side by side.

Categories

Resources