【发布时间】:2012-03-02 13:17:16
【问题描述】:
我的 ListView 有一个简单的选择器
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/yellow_arc" android:state_activated="true"/>
<item android:drawable="@drawable/yellow_nonarc" android:state_activated="false"/>
</selector>
当视图的状态从激活变为未激活时,我想为这些可绘制对象之间的过渡设置动画,反之亦然。
如果您在 API 演示中运行 example,您将看到一个明显的淡入/淡出动画,同时更改视图的激活状态。
所以我想要的是在视图状态发生变化时自定义动画。我认为应该通过 xml 来完成,但我找不到方法。
提前致谢。
编辑:
我想我发现了一些有用的东西,activated_background.xml 中有一个 \Android\android-sdk\platforms\android-API_VERSION\data\res\drawable,其中包括
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:state_activated="true" android:drawable="@android:drawable/list_selector_background_selected" />
<item android:drawable="@color/transparent" />
</selector>
因此,API-demos 中的示例通过声明exitFadeDuration 来实现此淡出动画。但是,这不是我想要的。我想声明 自定义动画 用于状态可绘制对象之间的转换,因为淡入/淡出动画不看起来很适合我的可绘制对象。
【问题讨论】:
标签: android animation android-listview transition