0

I get O from my SurfaceView object allthough inside the constructor I get a non zero value inside the constructor.

        mView=new MainView(this);
        FrameLayout fL=new FrameLayout(this);
        fL.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));

        Button zoomIn=new Button(this);

        zoomIn.setLayoutParams(new LayoutParams(mView.getwidth()/50,mView.getwidth()/50));
        zoomIn.setX(mView.getwidth()/2);
        zoomIn.setY(mView.getHeight()/2);
        zoomIn.setOnClickListener(new OnClickListener(){

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                mView.mThread.testzoom(1.5f);
                mView.mThread.zBackground.setZoomedBitmap();
            }

        });

        fL.addView(mView);
        fL.addView(zoomIn);


        Log.e("MainActivity","First Start of MainActivity");
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                             WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(fL);

I just simply want my button to be centered on frame layout...(the layoutparams are from framelayout because I am importing it so jsut need to call LayoutParams.xxxxxx)

Why is it so? My Buttons have 0 dimensions in x and y!!!

Ilja KO
  • 1,272
  • 12
  • 26
  • Check out this : [link](http://stackoverflow.com/questions/3591784/getwidth-and-getheight-of-view-returns-0?rq=1) – Akash Singh Oct 02 '15 at 05:58
  • yeah but I use my SurfaceView to get the width and height. In the constructor of the SurfaceView when I do new MainView(this) the getWidth() and getHeight return non zero. But a few clocks later outside of constructor it does?.....a bit strange....does it have something to do with my fullscreen flags. I know that I must them in specific order I think right before setContent View so I thought its ok like that but it maybe affectiong the button...what do you think? – Ilja KO Oct 02 '15 at 07:24

0 Answers0