Simple Property Animation
Before you start animating, you will want to inflate and bind your layout in MainActivity, in the onCreate(…) function.
Listing 25.5 Inflating and binding the layout (MainActivity.kt
)
class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) } }
Now, it is time to animate the sun down below the horizon. Here is the plan: Smoothly move binding.sun so that its top is right at the edge of the bottom of the sky. Since the bottom of the sky and the top of the sea ...
Get Android Programming: The Big Nerd Ranch Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.