C.d*_*.d. 36 animation android transition android-listview
我的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>
Run Code Online (Sandbox Code Playgroud)
当视图的状态从激活变为未激活时,我希望为这些绘图之间的过渡设置动画,反之亦然.
如果您在API演示中运行示例,则会在视图的激活状态发生更改时看到明显的淡入/淡出动画.
所以我想要的是一个自定义动画,同时改变视图的状态.我认为它应该通过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>
Run Code Online (Sandbox Code Playgroud)
因此API演示中的示例通过声明一个来实现这个淡出动画exitFadeDuration
.然而,这并不是我想要的.我想为状态drawables之间的过渡声明自定义动画,因为淡入/淡出动画对我的drawable来说看起来不太好.
在api 21"StateListAnimator"中添加
http://developer.android.com/reference/android/animation/StateListAnimator.html
我知道这是一个老问题,但这可能有助于未来的人们这样做.
Is it the fade you want?
我想它与 textSwitcher 的工作方式相同,也许您想将其更改为 ViewSwitcher,淡入淡出是通过编程语法完成的
Animation in = AnimationUtils.loadAnimation(this,
android.R.anim.fade_in);
Animation out = AnimationUtils.loadAnimation(this,
android.R.anim.fade_out);
mSwitcher1.setInAnimation(in);
mSwitcher1.setOutAnimation(out);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20269 次 |
最近记录: |