Android viewBinding is not binded some views in layout - android

I have a problem with viewBinding. I use buildTools 28.0.3 and Android Studio 4.1.2
I have a layout with more than 50+ views. The binding class is generated normally but there are around 40 views that has been generated. I cannot figure out why the rest views are not generated. They are the same view's type as the generated views.
Anybody face this issue before?

I found the cause of this issue. It's because I include "&" in layout file (even I put them in comment secion). I remove that character and re-build then everything is good.

Related

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!

ListView tools:listitem not working in android studio 2.2 stable channel

Steps to Reproduce:
Open Layout editor
Add a ListItem
Specify tools:listitem property with a valid row_layout
What should happen:
It should use the layout from tools:listitem to render list items.
Actual result:
Nothing changes, it still shows the default list with generic views
Bug Report
I could see this bug was already filed on Jul 5, 2016 Bug Report Link
Are there any work around available to render list?
One thing to notice: it's tools:listitem not tools:listItem which is somewhat confusing. Took me some time to figure that out, since Android Studio currently doesn't provide autocompletion for that.
You must define an id i.e. android:id="#+id/list_view" to your list
Another reason why tools:listItem doesn't work is when you're using the AndroidX's RecyclerView when using an older Android Studio. Update to 3.2 or higher and it will work.
This is fixed in Android Studio 2.3 beta 1
File -> Invalidate Caches and Restart
fixed the issue for me

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

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.

How to scroll a scrollable layout in the Android Studio?

I've imported my Project form Eclipse into Android Studio and I can't find the way to scroll my scrollable layout in the program (of course I am sure it is scrollable - I can scroll in the Eclipse and on a device).
According to this change set: https://android-review.googlesource.com/#/c/61089/ , there is a fix for this coming soon. I'd hazard a guess you'll see the fix in 0.1.7.
The fix bkromhout mentioned only works if the ScrollView is the root of the layout. I had put mine on top of the default RelativeLayout and had to manually fix that in the XML before the GUI would give me the full view. I hope this helps others who did the same.

Categories

Resources