Search code examples
androidtransparencyimagebuttonmvvmcross

android transparent ImageButton not clickable in MvvmCross


How does one create an ImageButton with transparent background that still clickable (still acts like a Button)?

This is the xml snippet:

 <ImageButton
            android:paddingRight="10dp"
            android:paddingLeft="10dp"
            android:paddingTop="7dp"
            android:paddingBottom="7dp"
            android:src="@drawable/serverschedule"
            android:background="@null"
            android:clickable="true"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="@string/predict"
            local:MvxBind="Click PredictCmd" />

I have also tried android:background="#00000000" and android:background="@android:color/transparent"and in all cases, I do get the desired visual effect but button no longer can be clicked.

I am using MvvmCross framework to binding to the Click event of the button, hence there is no code behind.

I am testing against API Level 15, if this matters.

EDIT Added entire axml for button. EDIT Adding MVVM framework as it may have something to do with problem.

TIA.


Solution

  • Thanks for all of the suggestions.

    This is what finally worked for me:

    android:background="?android:attr/selectableItemBackground"
    

    Based on responses from this thread.