当在开发工具里新建一个工程是,Eclipse会自动添加一个新的依赖库 appcompat_v7 或者 AS中会自动引用,并引用最新的主题样式Theme.AppCompat.Light。
appcompat_v7是应用兼容包,V7版本sdk 7(android 2.1系统),为了兼容2.1版本以上系统开发。 但你会发现现在的引用appcompat_v7包之前会出现app点击控件会有水波纹效果,但这水纹只会在sdk21以上出现,底版本不会,自己又兼容好了底版本有水纹效果,那就需要去掉appcompat_v7默认的效果,如何去掉?
在你使用的app主题里加上这个二项即可:
<item name="android:selectableItemBackground">@nullitem>
<item name="android:selectableItemBackgroundBorderless">@nullitem>
即:
<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
-- Background drawable for bordered standalone items that need focus/pressed states. -->
<item name="android:selectableItemBackground">@null
- "android:selectableItemBackgroundBorderless"
>@null
style>
<style name="AppTheme" parent="AppBaseTheme">
-- All customizations that are NOT specific to a particular API-level can go here. -->
style>
resources>
selectableItemBackground(API 11)、
selectableItemBackgroundBorderless(API 21)
但如果想使用v7包里的水纹效果可以设置自定义颜色: android:colorControlHighlight(API 21)
即:
<item name="android:colorControlHighlight">#000000
添加了报红,clear一下工程就好。