The
Soundcorset metronome and tuner, in which I wrote it with Scaloid, is keep growing and hits 70,000 downloads. Until recently, it has a strange problem that it displays very large text for some devices, so that some button texts are clipped away out of the layout. After some code investigation, I found that it is very tricky pitfall because the code does not seems to have any problem at first:
STextView("Hello").textSize(20 sp) // not correct!
The unit specification like
20 sp
is very common in Scaloid. The implicit function
sp
converts the number from the sp unit to the pixel unit. The code above looks fine because the most of the Android API receives a size as the pixel unit.
But there was a single exception. The method
TextView.setTextSize(float)
does not receives a size as the pixel unit, it receives sp unit instead. It may cause a mistake because the most of other APIs handles a size as the pixel unit, even in
TextView.getTextSize()
!!!
So I overridden
STextView.textSize
so that the APIs have consistency in pixel units:
@inline def textSize (p: Int) = textSize_=(p)
@inline def textSize_=(p: Int) = {
basis.setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, p)
basis
}
Now we can safely use the method
textSize
with the implicit unit conversions:
STextView("Hello").textSize(20 sp) // correct :-D
I patched the current snapshot, and it will be available at the next release of Scaloid.
The last thing you ever want to happen is to have your Android phone get severely affected with a virus. We are now living in the Information Age, where people are willing to exchange lots of bucks just to be able to take hold of powerful information. https://folder-lock-android.en.softonic.com
ReplyDeleteThe system look varies depending on the phone but the software itself has become better looking over time. Android's openness means that almost anyone can create an application on it.Download ShowBox APK
ReplyDeleteSome APIs are designed for a particular version of Android. Hence, these APIs do not work on devices powered by different versions of the mobile operating system.click this link here now
ReplyDeleteAndroid development requires a high level of ingenuity and imagination as well. An exposure to several verticals across a cross section of industries is also advantageous. Web Development Company
ReplyDeleteWhen we look at measuring trust, we enter murky waters. We measure in order to bring certainty to our initiatives. used test equipment auction
ReplyDeleteVery informative post! There is a lot of information here that can help any business get started with a successful social networking campaign.
ReplyDeletegbwhatsapp apk download
You will be surprised at the number of so-called professionals that slap the title app developer into their occupation. But with further inspection, it turns out that they know little to nothing about creating an app.gerald winata gozali
ReplyDeleteI am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy.
ReplyDeleteKroger experience
Thank you very much for this great post.
ReplyDeletehttps://tellthebelll.us
You’ve got some interesting points in this I would have never considered any of these if I didn’t come across this. Thanks!.
ReplyDeleteKroger customer survey