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);
I'm trying to create my first app in Android Studio with Kotlin. The installation worked fine. However if I drag any element onto the Layout, it's not showing up properly. The only change I can see, is a little white dot, that appears as soon as the Layout contains any element. I can select it and view the element attributes on the right, but nothing more.
If I run the app, all elements are squashed in the top left corner.
I already reinstalled Android Studio.
Does anyone know how to fix my problem?
Thaks in advance!
Here is some more information:
XML Code,
Error messages
Make the constraint layout width and height as match_parent in text editor. and then try adding widgets in the design view.
Here is some more information:
XML Code,
Error messages
I'm setting up two small buttons but in the graphic layout the text comes cut off
But when I run the app the text displays correctly or at least how it is expected.
I know this might be an eclipse configuration but I can't seem to find it.
Any ideas?
Edit: I forgot to add the xml configuration.
http://textdump.net/read/4292/
I have a transparent layout used for holding a banner advert in my app. The layout sits on top of my game area constantly, but the ads only appear once in a while. The code works as follows:
transparent_linearlayout_to_hold_banner.setBackgroundColor(Color.TRANSPARENT);
game_frame_layout.addView(transparent_linearlayout_to_hold_banner);
setContentView(game_frame_layout);
When I want an ad to be shown I do a
transparent_linearlayout_to_hold_banner.addView(adView);
When I want the ad to disappear I do a
transparent_linearlayout_to_hold_banner.removeView(adView);
This works perfectly on my Galaxy S !! with 4.0.3, but on my Galaxy tab with 2.3 I find that my transparent_linearlayout_to_hold_banner turns black as soon as the add appears, and remains black forever more, even when the ad is removed.
Any idea what is happening?... and how to fix it?
EDIT: after some experimentation, I worked out that the colour of the layout is not changing, but the alpha channel is. My guess is that perhaps the SDK of the banner ad system is calling some function(s) to make sure that the banner itself is not transparent, and then (depending on the OS version) this is having the side effect of making its parent layout non-transparent.
Try making the layout non transparent before adding the ad banner.
When you want to remove the ad, remove the ad banner view and make the layout transparent again.
Can you try adding this line again after you remove the ad.
transparent_linearlayout_to_hold_banner.setBackgroundColor(Color.TRANSPARENT);
If you're using admob, try latest 6.0 library, it has several improvements (as I can see) in control over the look of ad, it seems to pay more attention to the attributes described in Best Practices: Specifying ad colors. I had similar problem with previous release of the library. Yet, it doesn't allow alpha-channel, so you wouldn't be able to specify transparent background of the ad, but it may solve your problem.
try to make the layout that you want to be transparent in XML, not dynamically. I had such problems on dynamically added ListView with transparent Items.
You have a game here, so of course what I suggested might not work, or will be hard to do, but you can Use a FrameLayout to put your layout on which you draw, and the transparent one on top of it. Also note, in such case the touches will go to the ad layout. It can be prevented, but is a bit like of a hack (I did it by the way once).
I don't know if this will work, but give a try.
some ideas:
can you simply remove the line of setting the background to the lineraLayout :
transparent_linearlayout_to_hold_banner.setBackgroundColor(Color.TRANSPARENT);
?
also , instead of removing and adding the adView , can you instead toggle the visibility of the linearLayout (or the adView ) ?
I am new to programming in Java and Android. I got admob to work at the most basic level, and whenever the device is at the landscape orientation, admob tends to popup and occupy a huge potion of the screen.
What is the best way to detect the orientation and hide the ads from displaying if it is in horizontal orientation? Is it necessary to put the admob application in a thread to check for change in orientation and hide/unhide it?
Please advice.
Thanks!
Can you just not include it in your layout XML file for landscape? You can have a landscape version of your layout by including "-land" at the end of the layout folder name. For example:
/res/
/layout/
/main.xml
/layout-land/
/main.xml
If main.xml is the layout you have loading for an activity, the OS will automatically load the one in the layout-land folder for when the phone is a landscape orientation. Therefore in that XML file you can re-adjust the admob ad in the layout or remove it completely (if it is a layout object? I've never user admob).