Created
July 23, 2020 13:56
-
-
Save momvart/14e5feecebb397995f9296f3b8f5c59e to your computer and use it in GitHub Desktop.
Add support of baseline to constraintlayout Placeholder. When you want to set baseline constraint on a Placeholder doesn't work because it doesn't support it. With this simple extension you can solve the issue.
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
import android.content.Context | |
import android.util.AttributeSet | |
import androidx.constraintlayout.widget.Placeholder | |
// You can replace it with Placeholder when you want to set layout_constraintBaseline_toBaselineOf | |
class PlaceholderWithBaseline @JvmOverloads constructor( | |
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 | |
) : Placeholder(context, attrs, defStyleAttr) { | |
override fun getBaseline(): Int = | |
content.baseline | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment