<ImageView style="@style/LoaderPrevNext.Next" />
Run Code Online (Sandbox Code Playgroud)
使用样式
<style name="LoaderPrevNext">
<item name="android:layout_width">40dp</item>
<item name="android:layout_height">80dp</item>
<item name="android:layout_weight">0</item>
<item name="android:scaleType">fitXY</item>
</style>
<style name="LoaderPrevNext.Next">
<item name="android:src">@drawable/next_page</item>
<item name="android:contentDescription">@string/img_desc_next_page</item>
</style>
Run Code Online (Sandbox Code Playgroud)
[Accessibility] Missing contentDescription attribute on image警告让我很生气.
如果我将contentDescription从样式移动或复制到ImageView标签,它就会消失,但由于src是在样式中定义的,我很乐意将它们保持在一起.
猜猜这只是一个SDK bug,但有些可能会有一个解决方法......
澄清:有问题的ImageView确实有一个内容描述,在LoaderPrevNext.Next样式中定义.警告是错误的.我对如何设置内容描述或如何将其破解为空的想法不感兴趣.