• 7
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I have very simple checkbox:

<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/clipboardBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:button="@drawable/clipboard_checkbox" /> 

For checked/unchecked I have two different images.

After migration to AndroidX I see default image for Android on devices below API 21.

What I've tried already:

  • change CheckBox to AppCompatCheckbox (from AndroidX) - nothing changed
  • set background to checkbox & set android:button="@null" - background is OK, but I still see default image on background (see image below)

Seems that Android completly disrespect button attribute.

example of background set to img and button to null

I am out of ideas. For Lollipop+ everythink works as it should. Have anyone faced issue like this? Only change I did was migration to AndroidX :/

      • 2
    • Actually, now that I look again, it should fall back to the regular button attribute if buttonCompat isn't there. That might be a bug, if reliably reproducible.
      • 2
    • Upon a quick glance at the source, it looks like AppCompatCheckbox uses the buttonCompat attribute instead. That'll be in your app's namespace, btw; i.e., xmlns:app="http://schemas.android.com/apk/res-auto", app:buttonCompat="@drawable/clipboard_checkbox".

In the appcompat theme, the checkBoxStyle below API 21 is defined as

    <style name="Base.Widget.AppCompat.CompoundButton.CheckBox" parent="android:Widget.CompoundButton.CheckBox">
        <item name="android:button">?android:attr/listChoiceIndicatorMultiple</item>
        <item name="buttonCompat">?attr/listChoiceIndicatorMultipleAnimated</item>
        <item name="android:background">?attr/controlBackground</item>
    </style>

the attr buttonCompat has a default value to show the click animation. The attr buttonCompat take effect and ignore the button attr.

To fix it, the attr buttonCompat must be undefined. In your theme add

    <item name="checkboxStyle">@style/MyCheckBox</item>

and add a style

    <style name="MyCheckBox" parent="android:Widget.CompoundButton.CheckBox">
        <item name="android:button">?android:attr/listChoiceIndicatorMultiple</item>
        <item name="buttonCompat">@null</item>
        <item name="android:background">?attr/selectableItemBackgroundBorderless</item>
    </style>

Also in your values-v21 dir, add this to your theme

    <item name="checkboxStyle">?android:attr/checkboxStyle</item>
  • 1
Reply Report

You need to set the button and buttonCompat null for androidx libraries. It will look like below-

 <androidx.appcompat.widget.AppCompatCheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:button="@null"
                app:buttonCompat="@null"
                android:background="@drawable/cb_pause_resume_selector"
                />
  • 0
Reply Report

Change CheckBox to AppCompatCheckBox(AndroidX) and replace android:button to app:buttonCompat

  <androidx.appcompat.widget.AppCompatCheckBox
    android:id="@+id/clipboardBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_chainStyle="packed"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/email_sign_in_button"
    app:buttonCompat="@drawable/clipboard_checkbox" />
  • 0
Reply Report