Created
November 23, 2015 09:37
-
-
Save junlincao/717fda6ce4e089696ec0 to your computer and use it in GitHub Desktop.
android 5.0 ripple 写法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
写ripple drawable时候,如果默认背景带透明度,则item加一个id="@android:id/mask",以保证边界: | |
<ripple xmlns:android="http://schemas.android.com/apk/res/android" | |
android:color="?android:colorControlHighlight"> | |
<item android:id="@android:id/mask"> | |
<shape> | |
<corners android:radius="4dp" /> | |
<solid android:color="@color/white" /> | |
</shape> | |
</item> | |
<item> | |
<shape> | |
<stroke | |
android:width="1px" | |
android:color="@color/divider_color" /> | |
<corners android:radius="4dp" /> | |
<solid android:color="@color/transparent" /> | |
</shape> | |
</item> | |
</ripple> | |
否则,可以不用 mask id,如: | |
<ripple xmlns:android="http://schemas.android.com/apk/res/android" | |
android:color="?android:colorControlHighlight"> | |
<item | |
android:id="@android:id/mask" | |
android:drawable="@color/white" /> | |
</ripple> | |
.9图则直接在item中放nine-patch | |
添加多个状态,则在item中放selector 如: | |
<ripple xmlns:android="http://schemas.android.com/apk/res/android" | |
android:color="?android:attr/colorControlHighlight"> | |
<item> | |
<selector> | |
<item android:state_enabled="false"> | |
<nine-patch | |
android:src="@drawable/yourninepatch" | |
android:alpha="?android:attr/disabledAlpha" /> | |
</item> | |
<item> | |
<nine-patch android:src="@drawable/yourninepatch" /> | |
</item> | |
</selector> | |
</item> | |
</ripple> | |
估计带透明背景也得加mask,待测试! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment