我正在使用 AndroidX 支持库。在我的清单文件中,我声明:
<application
...
android:theme="@style/AppTheme">
在
values.styles.xml
中,我声明:<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="android:imageButtonStyle">@style/MyImageButton</item>
</style>
<style name="MyImageButton" parent="Widget.AppCompat.ImageButton">
<item name="android:background">@android:color/transparent</item>
</style>
接下来,我通过以下方式使用ImageButton:
<ImageButton
android:id="@+id/image"
android:layout_width="40dp"
android:layout_height="40dp" />
很遗憾,我的ImageButton
显示的是灰色背景而不是透明的背景。我该怎么做才能修复它?