I have a custom toolbar icon (I needed a toolbar icon with text always visible next to it).
When I inspect my code with Lint, I receive the warning that shape is not allowed here. As much as I understand, I should enclose the shape with item tag, but once I do that the ripple effect is not working on my custom toolbar icon. This is my current code
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<corners android:radius="5dp" />
</shape>
</ripple>
What would be a correct approach to this? I tried moving the shape to a separate drawable file and then referencing it with <item android:drawable:"@drawable/shape"/>
and it loads the correct icon and layout, but ripple is gone then.
Weird, but using just the following for a background of my custom toolbar icon layout does the trick and keeps Lint from complaining.
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
</ripple>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments