Ad
Setting Default Background Of ImageButton To Transparent (using AndroidX)
I'm using the AndroidX support libraries. In my manifest I declare:
<application
...
android:theme="@style/AppTheme">
In values.styles.xml
I declare:
<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>
Then I use the ImageButton via:
<ImageButton
android:id="@+id/image"
android:layout_width="40dp"
android:layout_height="40dp" />
Unfortunately, my ImageButton
shows a grey background instead of the transparent one. What do I have to do to fix it?
Ad
Answer
You need to replace this line
<item name="android:imageButtonStyle">@style/MyImageButton</item>
with
<item name="imageButtonStyle">@style/MyImageButton</item>
And This is also another way given by @prince
Ad
source: stackoverflow.com
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View
Ad