React Native Android Clipping Children - android

I am creating a react native app using expo, and I am creating a dropdown in the header. On iOS the dropdown works as desired, and goes 'above' the main content, while on Android it is clipped or goes 'under'. I am not sure if in reality iOS is acting strange, or Android is.
The header is a custom headerTitle component, which holds the custom dropdown component (a view, which holds the dropdown items (Views with text and icons)
I am looking to get around this issue, and I have tried zIndex and absolute positioning (which I have read does not even work on android, but thought I would try), and that did not fix it (and caused other issues).
Any tips, tricks, and better understanding of why this happens on iOS and Android would be greatly appreciated. I can post code if necessary as well.

React Native does not support overflow: 'visible' on Android.
A good example to look at for this is here: https://github.com/brentvatne/growler-prowler/blob/0eebfaae641a088b1a1fd7ffe552deeac914bffe/screens/BreweryListScreen.js#L70-L76
The key here is to render the menu component inside of a modal (in this case I'm using react-native-root-modal) in order to have it appear on top of the header.

Related

Android 10: 3-button navigation is obscuring bottom of the screen

I have had feedback from Pixel 3/4 users that the bottom of the screen on this app is cut off, obscuring buttons and possibly other controls that the user requires.
This has only started happening on Android 10. The app contains both Xamarin.Android axml and Xamarin.Forms xaml layouts for the views (the particular page that you are viewing below is Xamarin.Forms).
I don't want to set margins, paddings, gravity or such like on the entire app as obviously that would impact non Android 10/Pixel users. I don't really want to check the operating system version and programatically change those properties as that seems quite hacky and will quickly become unmanageable.
I've looked for something similar to a UseSafeArea property for navigation bars rather than notches but there doesn't seem to be any. Is using WindowInsets the only way to this or has someone else had/solved this issue?
How it looks (controls at bottom are obscured):
How it should look (and does on every other device, the data is different here but it's the view that matters):
I had a similar issue which I solved by removing a few lines of code that were there to fix a bug that has since been fixed in Xamarin Forms.
It directly relates to this forum topic: https://forums.xamarin.com/discussion/87176/windowsoftinputmode-doesnt-work-in-xamarin-forms-android
If these lines exist in your MainActivity.cs, try removing them and see if that works:
Window.SetSoftInputMode(Android.Views.SoftInput.AdjustResize);
Window.SetSoftInputMode(SoftInput.StateHidden);
AndroidBug5497WorkaroundForXamarinAndroid.assistActivity(this);

Android Studio does not show anchor points when laying out a custom component in a ConstraintLayout

I've developed a super simple custom View in Android, to be used as a generic placeholder, that just shows a diagonal line between the upper-left vertex to the lower-right one.
The problem is that when I try to lay out it in a ConstraintLayout, the editor does not show the anchor point I would expect. An image is worth a thousand words:
If you're experienced with Android Studio you know that if I were using a standard View, like a Button, instead of mine custom View, the green arrow should normally hook to the grey "BUTTON", representing a vertical constraint.
Any idea why Android Studio does not behave as expected ?
It is an Android Studio bug or maybe my custom view misses something else like some callback method ?
It is worth to mention than if I manually edit the layout XML writing the proper contraints and then I reopen the view, it is shown correctly, with all the arrows representing contraints in place! Even the one that I was not able to draw in the first place.
Ok, the answer was quite easy. In order to properly work, it is mandatory to assign an android:id to all components. If some components involved in a ConstraintLayout do not have it, it is impossible for Android Studio to set such constraint. This is because a constraint has this kind of form:
app:layout_constraintTop_toBottomOf="<ID OF THE COMPONENT ATTACHED TO>"
So... in my case it was enough to ensure all components, be them custom or default ones, have an ID.

Is it possible to add custom interactive UI elements to EditText?

A bit of context here. I'm an iOS developer with no knowledge on Android development.
I need to know whether it's feasible in Android to embed custom interactive UI elements (in iOS that'd be a UIView) inside of EditText.
A library I found to do this in iOS is: https://github.com/vlas-voloshin/SubviewAttachingTextView
You can see a GIF in that link showcasing the kind of behavior I'm looking for.
Is there built in support, or any third party library I can use to achieve something similar in Android?
in normal way this is not possible in android and we don't have any standard component or any library (that i know) for doing such a thing but we can create something similar to this (for this you should search about custom Views in android !) and also there is other way and easier way to achieve something similar to this is using the container layouts in android like LinearLayout and adding all your component to that container layout in run-time base on your text ! for example in your code you can dive in to your text and find tags like or and create appropriate view for your tag and add it to your container layout and at the end your layout looks like that gif wich is in your question ! and also in android we can show some basic html code in textView

React Native DrawerLayout: shadow on child appears on iOS but not on Android

I have an app that uses Expo's GestureHandler.DrawerLayout with the "back" drawer style, such that the view rests atop a stationary drawer and slides off to reveal it. To emphasize this arrangement, I wanted to add a drop shadow to the content View, cast on the drawer content. So far, I have this working on iOS but not on Android.
To explore this in isolation from the rest of my app, I've forked the react-native-gesture-handler project and modified the horizontalDrawer example app. I've added style props for the shadow here:
https://github.com/kmagiera/react-native-gesture-handler/compare/2542bd39503412ef00883e0e799caf7d1f68ef3a...brettdh:shadows-broken-on-android
As you can see in this screenshot, the shadow appears on iOS, but not on Android. However, if I remove absolute positioning by commenting out this line, I see that the shadow is actually being clipped on the left, as you can see in this screenshot.
I've dug into the component tree a bit and tried:
moving the shadow props to a wrapper View
clearing overflow: hidden
(though now my understanding is that overflow: visible only works on iOS)
I've found discussions describing this as having something to do with absolute positioning, but even if that's the case, I don't think I can avoid that, as it's part of the DrawerLayout itself. Any thoughts as to how I can accomplish the same shadow effect on both iOS and Android?
Some further investigation indicates that DrawerLayout puts a View around my component that's (probably) clipping the shadow. If I put my elevation prop on that View instead (along with a backgroundColor), the shadow is no longer clipped.
This probably means that I need to make a PR to enable custom styles on this wrapper View.

Android Tweetdeck-like UI

I'm getting started with Android development, and I would like to have an interface similar to that of tweetdeck: there are several workspaces (activities) that are laid out left to right, and the user can switch between them with a horizontal gesture. The same way the Android desktops are switched.
In tweetdeck there are also dots in the titlebar, that indicate on which side and how many workspaces there are.
Is it a standard Android interface, or something custom built? How do I do something like this?
How you go about this is going to be partially dependent on the content you want to present. If there are going to be many heavyweight pages you'll want to look into doing something like a custom AdapterView. If there are only a few fixed pages such as in the stock home screen you can treat it like a scrollable view with some custom logic to handle snapping to pages.
Here's a link to the custom view that implements this in the stock Android launcher. The bits you're interested in will mostly be in onTouchEvent, onInterceptTouchEvent, and computeScroll.
https://android.googlesource.com/platform/packages/apps/Launcher2/+/master/src/com/android/launcher2/Workspace.java
Take a look at ViewFlipper: http://developer.android.com/reference/android/widget/ViewFlipper.html
In addition to studying the actual Android code (referenced in another answer), some folks have extracted and isolated the workspace (Launcher2) code into a re-usable view group. You can find the work in github here https://github.com/olibye/AndroViews

Categories

Resources