Skip to content

Instantly share code, notes, and snippets.

@momvart
Created July 23, 2020 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save momvart/14e5feecebb397995f9296f3b8f5c59e to your computer and use it in GitHub Desktop.
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.
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