The correct way to completely uncheck a checkbox in API 16 and below

I have a problem hiding the boxes of my CheckBox . My CheckBox looks like this:

 <CheckBox android:id="@+id/favoritesBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:button="@null" android:tag="1" android:textStyle="italic" android:text="@string/details_tags_favs" /> 

The only problem is that button=@null removes its style and does not completely go away. Because of this, my text not centered, but moves to the right (the size of the window).

Is there a smooth way to completely get rid of it in API 16 and below?

+5
source share
2 answers

With a little help from Andrew T. with my RubberDuck debugging, I found a solution to this problem.

What you need to do is set background="@android:color/transparent to CheckBox and the invisible field will disappear from your View .

So my new CheckBox looks like this:

 <CheckBox android:id="@+id/favoritesBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:button="@null" android:background="@android:color/transparent" android:tag="1" android:textStyle="italic" android:text="@string/details_tags_favs" /> 
+6
source

The following property works for me.

 android:button="@null" 
0
source

Source: https://habr.com/ru/post/1201544/


All Articles