Neo*_*eoh 38 android material ripple rippledrawable android-5.0-lollipop
我有不同的draw9patch按钮png
作为背景.目前按钮的控制方式selector
如下:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/disabled" android:state_enabled="false"/>
<item android:drawable="@drawable/focused" android:state_focused="true"/>
<item android:drawable="@drawable/default"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
对于Android Lollipop,他们有RippleDrawable
触摸效果,如下所示:
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight">
<item>
...
</item>
</ripple>
Run Code Online (Sandbox Code Playgroud)
关于新的触摸波纹效果:
1:我可以将draw9patch设置为背景RippleDrawable
吗?
2:我如何容纳以上两种不同的xml我想遵循材料设计?我是否必须为新的文件夹/布局xml分叉RippleDrawable
?
ala*_*anv 78
1)是的.有关如何合成图层的更多详细信息,请参阅RippleDrawable的文档,但基本上您需要:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight">
<item android:drawable="@drawable/yourninepatch" />
</ripple>
Run Code Online (Sandbox Code Playgroud)
或者还要以干净的方式处理禁用状态,您可能需要:
<?xml version="1.0" encoding="utf-8"?>
<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>
Run Code Online (Sandbox Code Playgroud)
2)是的,你应该将你的纹波XML放在drawable-v21中.
归档时间: |
|
查看次数: |
31856 次 |
最近记录: |