2012-03-13 2 views

답변

2

ImageView에 알파 애니메이션을 적용 할 수 있다고 생각합니다. fillAfter()가 true로 설정되어있는 한 이미지는 알파 수준으로 유지되어야합니다. 에서 끝납니다.

+0

API 레벨에서 작업 이미지 뷰 그게 전부에뿐만 아니라 setAlpha (INT 알파)가 .. API 레벨 1에서 사용할 수 있습니다 .. . 위 참조. – joynes

+0

확실히 이동하는 방법입니다 – FoamyGuy

40

ImageView은 API 레벨 1부터 메소드 setAlpha(int)입니다. 따라서 모든 API 레벨에서 사용할 수 있습니다.
은 API 수준에서 도입 ViewsetAlpha(float) 방법은 11

+3

@joynes 대답을 받아 들여야합니다 – ruX

+1

SDK 버전이 16 이상이면'setImageAlpha (X)'를 사용하십시오! – tipycalFlow

+0

나는 마지막 코멘트가 훨씬 더 유용하다고 생각한다. – Vyacheslav

2

당신은 오버레이로 설정하면 레이아웃에 필요한 알파를 설정, 단지 UR 이미지와 새로운 레이아웃을 만들 때 팽창 수 필요.

LayoutInflater inflater = LayoutInflater.from(this); 
     View overView = inflater.inflate(R.layout.myAlpahImageLayout, null); 
     this.addContentView(overView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:alpha="0.5" 
    tools:context=".MainActivity" > 

    <ImageView 
     android:id="@+id/myImage" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/myImage1" /> 

</RelativeLayout> 
4

코드를 사용하여보기가 아닌 이미지 자체의 알파를 설정합니다. 이

public void toggleButton(int i) { 
    if (indImageBtnEnabled[i]) { 

     int di = getDrawableId(findViewById(myImagebtns[i])); 
     Drawable d = this.getResources().getDrawable(di); 
     d.setAlpha(25); 

     ((ImageView) findViewById(myImagebtns[i])).setImageDrawable(d); 

     indImageBtnEnabled[i] = false; 
    } else { 
     // findViewById(myImagebtns[i]).setAlpha(1f) << NEEDS API11; 
     int di = getDrawableId(findViewById(myImagebtns[i])); 
     Drawable d = this.getResources().getDrawable(di); 
     d.setAlpha(255); 

     ((ImageView) findViewById(myImagebtns[i])).setImageDrawable(d); 

     indImageBtnEnabled[i] = true; 
    } 
} 
관련 문제