Search code examples
androidandroid-radiobuttonandroid-appcompat

AppCompatRadioButton not shown


Since I want to use buttonTint on versions < 21, I need to switch from RadioButton to AppCompatRadioButton. Unfortunately the button is not shown on the device (Android 5.1). It's strange because the android:text of the AppCompatRadioButton works, so that means that the button basically works. Only the circle is not shown. Any ideas why? I also tried to set other color attributes which come with AppCompatRadioButton. It didn't work either. I also updated to the latest compatibility package, I moved the button inside the xml to another position, but nothing works.

This is the xml definition:

<android.support.v7.widget.AppCompatRadioButton
    android:id="@+id/radio_bronze_monthly"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:onClick="onBillingRadioButtonClicked"
    android:text="@string/bronze_monthly"
    android:textColor="@color/black"
    android:textSize="@dimen/default_text_size"
    app:buttonTint="@color/black"
    app:colorAccent="@color/black"
    app:colorPrimary="@color/black"
    app:colorPrimaryDark="@color/black"/>

Solution

  • I figured out what was wrong: Inside the Activity declaration in AndroidManifest, I set my own transparent theme which is used in other Activities too:

    <activity
        android:name=".domain.billing.BillingActivity"
        android:noHistory="true"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.Transparent">
    </activity>
    

    This is from styles.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <resources xmlns:android="http://schemas.android.com/apk/res/android">
    
        <style name="Theme.Transparent" parent="android:Theme">
            <item name="android:windowIsTranslucent">true</item>
            <item name="android:windowBackground">@android:color/transparent</item>
            <item name="android:windowContentOverlay">@null</item>
            <item name="android:windowNoTitle">true</item>
            <item name="android:backgroundDimEnabled">false</item>
        </style>
    
    <!--more styles -->
    </resources>
    

    if I omit this line, it works:

    android:theme="@style/Theme.Transparent"