Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set checkbox border color

The checkbox border is invisible on white background.

enter image description here

I played with different color parameters without success. I need black border of box. Yes, there examples to make custom checkbox. In all drawable examples the normal box is visible inside of new shape. And the drawable shape is narrow without text in android:text="".

enter image description here

But why checkbox does not look okay in usual xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/layoutBottom1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:orientation="horizontal"     android:background="#FFFFFF"     android:gravity="center" >     <CheckBox         android:id="@+id/checkBottom1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="AAAA"         android:visibility="visible"         android:textColor="#000000"         android:checked="true" />  </LinearLayout> 

Any ideas? Thanks!

like image 225
Niaz Avatar asked Oct 19 '14 05:10

Niaz


People also ask

How do you change a checkbox border?

Style the label with the width, height, background, margin, and border-radius properties. Set the position to "relative". Style the "checkbox-example" class by setting the display to "block" and specifying the width and height properties. Then, specify the border-radius, transition, position, and other properties.

How do I change the color of my check box?

“:hover” is used to style the checkbox when user hovers over it. Notice that when the mouse pointer move over the checkbox the color of it changes to yellow. “:active” is used to style the checkbox when it is active. Notice that when click the checkbox it will first notice a red color and then the green color.

How do I style a checkbox in CSS?

The checkbox is an HTML element used to take input from the user. It is hard to style the checkbox, but pseudo-elements makes it easier to style a checkbox. This HTML element is generally used on every website, but without styling them, they look similar on every website.


2 Answers

You can use the property

android:buttonTint="what you want" to set your checkbox border color.

like image 51
Caio Lucas Alcantara Avatar answered Sep 19 '22 01:09

Caio Lucas Alcantara


It's too late to answer but I would like to share what worked for me. Paste below code. It would change the CheckBox border color and textColor

styles.xml

<style name="MyCheckBox" parent="Theme.AppCompat.NoActionBar">     <item name="colorControlNormal">#000</item>   <!-- normal border color change as you wish -->     <item name="colorControlActivated">#000</item> <!-- activated color change as you wish -->     <item name="android:textColor">#FFFF3F3C</item> <!-- checkbox text color --> </style> 

now in your main_activity.xml place below CheckBox code

<CheckBox android:id="@+id/check_agree"           android:layout_width="wrap_content"           android:layout_height="wrap_content"           android:layout_margin="10dp"           android:text="I agree"           android:theme="@style/MyCheckBox"/>   <!-- here apply your checkbox style --> 

if above style not working then replace parent theme parent="Theme.AppCompat.NoActionBar" with parent="Theme.AppCompat.Light". Hope it would work.

like image 35
IPL10 Avatar answered Sep 19 '22 01:09

IPL10