2012-12-17 3 views
0

슬라이더를 열 때 슬라이딩 드로어 배경의 불투명도를 낮추고 닫을 때 불투명도를 높이십시오.드로어 슬라이딩 애니메이션

시도 슬라이더가 열리거나 닫힐 때 배경을 변경합니다. SlidingDrawer.OnDrawerOpenListener/SlidingDrawer.OnDrawerCloseListener, 내가 찾고있는 것이 아닙니다.

도움을 주시면 감사하겠습니다. TransitionDrawable

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

이 코드는 당신에게 흰색 (원래 색상) 노란색에서 같은 페이딩 효과를 제공하여

페이딩 색상 효과 : 여기

+0

은 투명 backgro에 설정되어 그 트릭을하고 있지 않니? –

+0

@AliImran 투명 이미지 설정이 잘되어 있습니다. 슬라이더의 높이에 따라 투명도가 증가하는 곳을 찾고 있습니다. 즉, 슬라이더가 25 % 열리면 투명도는 75 %가되어야합니다. 슬라이더가 완전히 열린 상태에서 투명도는 100 %이어야합니다. – vin

답변

2

는 예를 들어이 시도입니다.

translate.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>