Created
December 11, 2020 10:44
-
-
Save dadouf/f8de9e5f7599a474ecc922b8cc7406a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OverlayableImageView @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = 0 | |
) : ConstraintLayout(context, attrs, defStyleAttr) { | |
private val imageView: ImageView | |
private val sendButton: ImageButton | |
init { | |
imageView = ... | |
sendButton = ... | |
// android:animateLayoutChanges="true" for cross-fade | |
layoutTransition = LayoutTransition() | |
isActivated = false | |
} | |
override fun setActivated(activated: Boolean) { | |
val isChanging = activated != isActivated | |
super.setActivated(activated) | |
if (isChanging) { | |
// Switch between VISIBLE and INVISIBLE | |
sendButton.isInvisible = !activated | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment