Adapting to Samsung S8-like screens with 'blind pixels' - android

How to avoid 'blind pixels'? S8's round-cornered screen may affect layout in a significant way. How to know where I can safely draw anything, and where I have to be aware that some part of drawn pixels may never actually display?
I don't want to force non-fullscreen mode. I just want to know where is my "safe rect". How to get that information?
(possibly in a way that can be applied to every phone no matter what company manufactured it, but device-specific solutions are also very welcome)
edit: added picture for everybody still in 2016:

Related

How to modify the entire screen display in Android, even outside the app

I'd like to create an Android app that can modify the whole display, even when the app is not being used directly. This is one example of an app that seems to do this.
Ideally, I'd not only want to be able to tint the screen, but to perform arbitrary operations on the pixels being shown on the display, ranging between making the entire screen a solid color, inverting the colors (so that e.g. black becomes white), and blurring the screen. (I could imagine this level of access in the wrong hands could make somebody's phone unusable, so maybe not all of these are possible.)
Any pointers on how to do this?
You want to let your app draw over other apps. There is a special set of requirements for such applications.
Take a look here and here.
There is also a simple tutorial.
And an opensource app, that looks pretty similar to one you've linked above.

How to handle different screen resolutions for mobile phones in Unreal Engine? Specifically UI

I have looked around but, I am unable to find an answer to my question. Basically, I am creating a phone app. The only problem I seem to be having is with the menu UI. Basically, it is set to a 1080x1920 resolution, which is probably the most common one out there. However, it is not the only one. How do I handle multiple screen resolutions? Do I need to make like separate widgets for each resolutions and load in the correct one based on that? Or is there some other way that I am just not aware of. I am sure that others have come across this same problem too.
The reason I bring this up is because I have loaded the app onto a phone that is not 1080x1920 and the UI doesn't fit inside of it. I have tried messing with different settings on the UI but, nothing seems to fix it. Any help would be greatly appreciated.
There were two problems that were happening. The first reason why the UI wasn't scaling properly was because I was using a Size Box instead of just a plain Canvas Panel. It didn't matter what I did, the Size box would remain the same. Changing that would solve the first problem. The second problem that was happening was that because of the size box it forced my anchors to be centered instead of stretched. Once I replaced the Size Boxes with Canvas Panels I was able to make my panel anchors stretch to fill the screen.
I hope this helps anyone else that comes across this problem.

How can I overlay a lightning bolt on a custom battery charging image in a fragment?

I have an app that runs fullscreen, but needs to show the battery status. (It's for a fleet of rooted B&N Nooks, all eInk, Android 2.1, but with compatibility library.)
I'm running a fragment that has the battery icon in it. All of that works properly... it's displayed, it measures the right current voltage, and so. No issues there.
I want to overlay a "charging" lightning bolt, as is common, to indicate when the device is plugged in. Currently I have 16 PNGs with the battery in various states of charge and select between them with a big if statement. Meh, I only run it once every ten seconds, I'm not worried about performance there.
What I would like to do is have ONE lightning bolt image and just XOR it with the current battery image. That would give me the correct black and white portions as I go. So the question is how can I XOR one image with another?
The 'admit defeat' alternative is I could double the set of PNGs I have... one with charging bolt and one without. That would be sad though.
Here is a link to reverse an image pixels by pixels https://xjaphx.wordpress.com/2011/06/20/image-processing-invert-image-on-the-fly/
From this you could loop through both images, reverse the pixels on image A from the non-transparent pixels on image B. It should give you the effect you are looking for.
I don't know what language you are writing in but I think you need to use z-index in your CSS to layer images. Check out this page, he does a pretty good job of explaining it. what no one told you about z-index

How to fit every screen

So I am making a game in processing, but I'm not aware as to how to make my game fit every android phone's screen, I've looked online, but I can't seem to find anything about it in Processing.
I'm fully aware of displayWidth/displayHeight, but I'm not too sure on how to make my buttons to be all pressable, and never change their positions, I would've thought that it would be done by putting all the co-ordinates using something like displayHeight/2 etc. etc. But I've tested the game out on my phone(Samsung Galaxy S3), but the text is not aligned properly
If anyone could please help me, I'd be super grateful!
android devices have different screen size, so instead of using px you can use percentage(%) value for the screen i believe it is sp(a different unit than px) by using this the properties you set for an identity or element becomes constant for all devices

Possible to control positioning in Android precisely using XML

I wanted to know if it was possible to precisely position widgets on Android using XML files? From my experiments, precise position seems impossible via XML. Programmatically, I'm able to position things perfectly based on the device width and height. However, using XML and dip values, things seem to fall apart. Here's one example of what I mean.
Mark Murphy, on an article, wrote:
Some developers, perhaps those coming from the "drag-and-drop" school
of UI development, think first and foremost about the positions of
widgets. They think that they want certain widgets to be certain fixed
sizes at certain fixed locations. They get frustrated with Android
layout manager (containers) and may gravitate to the deprecated
AbsoluteLayout as a way to design UIs they way they used to.
That rarely works well even on desktops, as can be seen by
applications that do not handle window resizing very well. Similarly,
it will not work on mobile devices, particularly Android, with its
range of screen sizes and resolutions.
Instead of thinking about positions, think about rules. You need to
teach Android the "business rules" about where widgets should be sized
and placed, with Android then interpreting those rules based upon what
the device's screen actually supports in terms of resolution.
source
This leads me to believe that precise positioning is difficult with XML files. This is important for my app because I'm laying out widgets on a background image so that these widgets need to be placed exactly on a particular area so that the overall UI looks good. The aspect ratio needs to be preserved across resolutions. Can I do all this using XML files?
Thanks! Any help is greatly appreciated!
Yes you are able to pixel by pixel position your views using an absolute layout.
Last time I checked, which was a while ago, those drag and drop interfaces actually created one for you. (Actually just checking for the link seems that this class has been deprecated.)
However, I highly advise against using them. The reason is because you are coding for so many different screen sizes that providing pixel by pixel dimensions will certainly cause problems across devices.
What I would recommend is using a RelativeLayout. I actually use this type of layout for everything that I can. It lets you put your items to right of, or above and below other elements. This combined with padding and margin options in DIP (density independent pixels) should let you create anything that you want. And it should look nice on most devices.

Categories

Resources