+ // Get the current tab.
+ val tab = tabLayout.getTabAt(tabLayout.selectedTabPosition)!!
+
+ // Get the custom view from the tab.
+ val tabView = tab.customView!!
+
+ // Get the favorite icon image view from the tab.
+ val tabFavoriteIconImageView = tabView.findViewById<ImageView>(R.id.favorite_icon_imageview)
+
+ // Set the previous favorite icon.
+ tabFavoriteIconImageView.setImageBitmap(Bitmap.createScaledBitmap(previousFavoriteIcon, 64, 64, true))
+