0

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

尝试在滑块打开/关闭时更改背景 SlidingDrawer.OnDrawerOpenListener/SlidingDrawer.OnDrawerCloseListener ,这不是我想要的。

任何帮助深表感谢。

4

1 回答 1

2

这是一个例子,试试这个:

褪色效果与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>

新状态.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>
于 2012-12-17T11:58:22.267 回答