Skip to content

Instantly share code, notes, and snippets.

@stanch
Created September 29, 2013 13:45
Show Gist options
  • Save stanch/6752653 to your computer and use it in GitHub Desktop.
Save stanch/6752653 to your computer and use it in GitHub Desktop.
trait MyStyles extends LayoutDsl with MediaQueries with ExtraTweaks {
// sets text, large font size and a long click handler
def caption(cap: String)(implicit ctx: Context): Tweak[TextView] =
text(cap) + TextSize.large + On.longClick {
Toast.makeText(ctx, "I’m a caption", Toast.LENGTH_SHORT).show()
true
}
// sets large font size for high-density screens, medium font size for medium-density screens
// does nothing in other cases
def adaptiveSize(implicit ctx: Context): Option[Tweak[TextView]] =
hdpi ? TextSize.large | mdpi ? TextSize.medium
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment