I am trying to occupy as much space as available on notched android devices. In Flutter
development, there is widget called SafeArea
which automatically adjusts your view depending on whether the device has a notch or not. Even in iOS
development whenever we add constraints
using storyboard
, we can add it according to SafeArea
. But I couldn't find anything similar to it in Native Android development.
In my styles.xml
for v28 I have added something as follows
<style name="TPAFTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
But is it possible to detect whether device has Notch or not in layout file itself and adjust the layout according. I am using Constraintlayout
in my App. As my app has image at the top it gets cropped if the device has notch at the top. Any help would be appreciated.
from Is there any SafeArea Widget for Native Android development?
No comments:
Post a Comment