0

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");
        }
    }
Barett
  • 5,826
  • 6
  • 51
  • 55
Jhon Smith
  • 181
  • 2
  • 12

1 Answers1

0

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.

Nghia Bui
  • 3,694
  • 14
  • 21
  • 1
    I see the doc,and found my mistake, I should set RGBA_8888 in format that another attribute in windowManger.LayoutParams. Thanks for your help. – Jhon Smith Jul 14 '15 at 02:59