滑动抽屉动画



我需要在滑块打开时降低滑动抽屉背景的不透明度,并在关闭时增加不透明度。

尝试在滑块打开/关闭时更改背景 滑动抽屉.开抽屉打开听众/滑动抽屉.开抽屉关闭听众 ,这不是我要找的。

任何帮助都非常感谢。

这里有一个例子试试这个:

褪色效果与TransitionDrawable

RelativeLayout layout = (RelativeLayout) findViewById(R.id.Layout);
layout.setBackgroundResource(R.drawable.translate);
TransitionDrawable transition = (TransitionDrawable) layout.getBackground();
transition.startTransition(5000);

此代码为您提供淡入淡出的效果,例如从黄色到白色(原始颜色)。

翻译.xml

<?xml version="1.0" encoding="UTF-8"?>
   <transition xmlns:android="http://schemas.android.com/apk/res/android">
          <!-- The drawables used here can be solid colors, gradients, shapes, images, etc. -->
          <item android:drawable="@drawable/new_state" />
          <item android:drawable="@drawable/original_state" />
   </transition>

new_state.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape   xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
    <solid android:color="#FFFFA7"/>
</shape>

original_state.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape   xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
    <solid android:color="#FFFFFF"/>
</shape>

最新更新