Checkbox without text does not align horizontally

Viewed 2328

It appears that a checkbox without text behaves like it does have a small space text. Centering it horizontally moves it a bit to the left.

Any ideas on how to work around this inconvenience?

enter image description here

2 Answers

The problem is that (probably) the CheckBox element is an extension of a TextView with a DrawableLeft set.

If you want only the box without Text, would be probably better to use a ToggleButton with the custom image as state selector.

Another possible solution is to create your own CheckBox extension and override getSuggestedMinimumWidth() as suggested here

Hope this helps ^^

android:layout_width="wrap_content" removes the small space text. Then just let the constraint layout center the view.

Related