Posts

Showing posts from March, 2026

Room3 Alpha - Example (compatible with Room 2)

Image
Introduction Now Room3  is available in Alpha, it may be a good time to check it out and make sure it works with your current database. If you have never used a Room  database before, this blog should give you a working start point to see it in action. This is for people interested in testing Room3 and for people interested in Room in general. Beginners may want to give this a try just so they can see a database in action. I will not go into too much detail about Room itself in this post, but you can see how to quickly get something up and running. More advanced programmers may just want to check out the dependencies as a reference, but you may be interested in how I access my Database and pass it into the ViewModel . Goal As well as setting up a Room database that will work with both Room2 and Room3 (depending on which dependencies you use), we will also add a ViewModel and Basic UI . The whole database design and functions in the example are exactly the same for Roo...

Animated Background with Pause

Image
Introduction & Purpose I sometimes like to add animated background to my apps to make them a little more interesting to work on, like in this very simple example above. Unfortunately, the animation is not free. It takes up CPU time, can waste battery, and also heat up physical devices. We definitely want to avoid that. It's also great to have a way to stop animations for people who are sensitive to motion. We could just remove the animated background, but this makes things a little boring if I want to show someone what I have been working on. We can fix this! I'll keep this post quick. Full code listing linked at the end. Animated Background Let's start with a basic animated background. This is our gradient and this will be reused with our final example. @Composable private fun DrawGradient ( offset: Float, modifier: Modifier = Modifier ) { Box (modifier. fillMaxSize (). drawBehind { val shift = offset * 3000f drawRect ( brush = B...