Skip to content Skip to sidebar Skip to footer

Align Checkbox Button To Center Of View

I'm trying to create custom checkboxes and I need to align it to the center of the checbox that will have its dynamic size according to the available width. Can someone tell me how

Solution 1:

You can achieve desired effect by making the following changes to your layout:

  1. Wrap each AppCompatCheckBox into RelativeLayout
  2. Move all the ConstraintLayout specific attributes from child to parent, including margins and 0dp width (you will also have to assign IDs to your RelativeLayouts and use them)
  3. Make sure all AppCompatCheckBox width is wrap_content
  4. Assign desired background of AppCompatCheckBox to corresponding RelativeLayout
  5. Make sure each AppCompatCheckBox is layout_centerInParent = "true"

That's about it!

Post a Comment for "Align Checkbox Button To Center Of View"