I am writing an application that builds a notification from several "symbols". Sometimes these won't fit and I'll just stop and add a number of symbols that did not fit.
Currently I'm looking at device's screen width to determine the number of symbols that do fit. Like this:
DisplayMetrics dm = resources.getDisplayMetrics();
int num = dm.widthPixels / height;
where height is "hardcoded" value of 64dp.
This does not work on tablets though. As result I'm losing rightmost symbols. Is there any way to determine the actual amount of space in my notification?
On this picture I'm using another hardcoded value of no more than 7 symbols total.
Are using height=64 or the equivalent of 64dp in pixels?
Why not get the width and height of your top layer to get the usable screen size instead of full screen size (including system and ActionBars)?
Here's the answer I've been waiting for: 478dp
Source
Which results in about 7.5 symbols per notification and having a value of 7 hardcoded is correct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With