Android Instant App + ConstraintLayout Group not working - android

I'm using androidx.constraintlayout.widget.Group in my androidx.constraintlayout.widget.ConstraintLayout to set the visibility of the entire group.
This works fine for a normal app but as soon as I run the same code as an Instant App it breaks and visibility is not applied.
Logcat posts an error like W/ConstraintHelper: Could not find id of "divider" for each view I've added to the group.
Is there any known bug / workaround for this?

It seems like there is a workaround: https://stackoverflow.com/a/54961700/2170109.
Thanks to #TWL pointing to it.
PS: I didn't test it since I moved to compose.

Related

Finding the name of the current activity from live layout inspector

I've got a physical device ready for debugging.
I want to track down the name of the curent activity using the Live Layout Inspector.
Seems like there's no such feature, but is there any roundabout way to do this?
Well, If you are using Android Studio Dolphin | 2021.3.1 or newer, there is no such straight way with layout inspector like the former version. However, you can find the related layout xxx.xml name,which could also help.
Touch any view, find Declared Attributes at the right panel,then shows the layout name, with which will find activty easily.
And also check this: Is there any way to track what fragment/s are visible right now?
Try the Profiler way.

Android studio code insight not showing everything

Android Studio shows code suggestions, but not all available codes are in the suggestion.
For example, layout_alignParentLeft will not be suggested, however, the documentation still shows it is a valid code.
Is there a setting that enables Android Studio to show all available codes?
Probably the parent of yourview is a ConstraintLayoutwhich doesn't have the attribute layout_alignParentLeft.
Try with a RelativeLayout instead and then you will see layout_alignParentLeft into the suggestions.

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

Android application experiencing strange layout when setting activity background

Here is the layout image.
The code that's causing the issue is as follows
View parent = calculateButton.getRootView();
Parent.setBackgroundColor(appSettings.getInt("app_background",r.color.White);
It works fine once the qpp key is there. However, the default key, no matter what it is, causes the layout bug.
I'm testing on a Nexus 6
EDIT: I believe i have solved it by replacing the default value for my getInt with an actual integer value rather than R.color.COLOR
Not sure what the root cause is, but it seems that whenever I used a color picker to set the color of the layout, it caused this weird rendering issue. I removed the feature, because I couldn't get it to render properly when the color was changed while the app was running.

Android+PhoneGap: android:windowSoftInputMode doesn't seem to work

I'm developing a PhoneGap-based application and I googled much about how to make my webview adjust its height when virtual keyboard appears, or at least get height of the virtual keyboard. I found a lot of posts (including stackoverflow) which says that
android:windowSoftInputMode="adjustResize"
must be set in the manifest and I did that. I also found that for PhoneGap config.xml there's
<preference name="android-windowSoftInputMode" value="adjustResize"/>
setting and I pasted that too. I also tried combined value 'stateVisible|adjustResize' (not just 'adjustResize') for both parameters, but it seems to me that they both have NO EFFECT. I don't know, maybe I'm doing something wrong, but you can check the screenshots from the emulator (Android 4.0.3, but I also tried 4.1.2 and 4.2.2):
http://screencast.com/t/Mm0mw8c693 - keyboard visible
http://screencast.com/t/lZ2DomqeRR - keyboard hidden
On the screenshot I intentionally captured my manifest and config.xml settings, so you may see they're actually there.
I even recorded short video - http://screencast.com/t/xI9PMcMJxxx
As you may see, no any viewport resizing occur when keyboard shown / hidden.
I also checked window.innerHeight using console.log() and it stays same for both visible and hidden keyboard.
Please, give me some advice.
windowSoftInputMode="adjustResize" does not work if your app is in fullscreen mode (setting fullscreen to true in config.xml). It is Android's issue not Cordova. the issue CB-4404 was filed in Cordova bug tracker for months but recently it turns out that it is working as intended on Android bug tracker.
I solved the problem by setting fullscreen to false since it wasn't a problem for my app not to go fullscreen.
I found I needed to to 3 things to resolve this issue, and prevent the actionBar from hiding itself, from scrolling out of view when the soft keyboard was brought up.
1) In AndroidManifest.xml, in the activity in question, I needed the line:
android:windowSoftInputMode="adjustResize"
The original problem is that adjustPan was present in the line above. At first, just the change above fixed the problem.
The project I am on uses fragments. In the onCreateView method, a different fragment had the line:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
That line, unfortunately, overrode the adjustResize parameter in the Application manifest, and after that other fragment was displayed, the fragment that I fixed broke again. So, to fix the new break, I did 2 additional things.
2) I deleted the SOFT_INPUT_ADJUST_PAN line from the onCreateView method of that other fragment, because it did not need that line anyway.
3) In the onCreateView method of the fragment with which I am primarily concerned, I added the line:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Actually, doing either of items 2 or 3 would solve the problem. I did both to be thorough.
either you can set this property in android.manifest explicitly to "adjustNothing" then you do not need to set "fullscreen" mode to false.
but you have to update it every time you update/add android platform.

Categories

Resources