I often use the attribute, but this time it is not work.If a remove the attribute,I can see the view and everything is ok. Do someone know what am i missed? myCode:
private boolean loadingDirect=false;
private void addLoading(){
loadingImg= new ImageView(mContext);
android.view.WindowManager.LayoutParams viewParams = new android.view.WindowManager.LayoutParams();
viewParams.x=0;
viewParams.y=0;
viewParams.width=600;
viewParams.height=600;
// viewParams.type=PixelFormat.RGBA_8888;
loadingImg.setImageResource(R.drawable.notice_loading);
loadingImg.setVisibility(View.VISIBLE);
loadingDirect=true;
loadingImg.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
if(loadingDirect){
Matrix matrix = new Matrix();
matrix.setRotate(180);
BitmapDrawable draw = (BitmapDrawable) mContext.getResources().getDrawable(R.drawable.notice_loading);
Bitmap bitmap= draw.getBitmap();
bitmap=Bitmap.createBitmap(bitmap,0, 0, bitmap.getWidth(),bitmap.getHeight(),matrix,true);
loadingImg.setImageBitmap(bitmap);
loadingDirect=false;
}else{
loadingImg.setImageResource(R.drawable.notice_loading);
loadingDirect=true;
}
}
});
try{
mWindowManager.addView(loadingImg, viewParams);
}catch(Exception e){
Log.d("NoticeBoardERROR", "addLoading");
}
}
Please take a look at http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html
Your viewParams.type does not expect PixelFormat.RGBA_8888 or PixelFormat.whatever; your code compile just because they are actually int numbers. But it is not an expected behavior.