Reputation: 1887
How can i change custom SurfaceView width and height. is this possible?
Upvotes: 13
Views: 24382
Reputation: 165
This is the right way to do it :
surfaceView.getHolder().setFixedSize(width, height);
Upvotes: 10
Reputation: 940
Following the kinds of possibles LayoutParams, maybe that's helpful for someone:
android.widget.TableRow.LayoutParams;
android.widget.TableLayout.LayoutParams;
android.widget.RelativeLayout.LayoutParams;
android.widget.RadioGroup.LayoutParams;
android.widget.GridLayout.LayoutParams;
android.widget.Gallery.LayoutParams;
android.widget.FrameLayout.LayoutParams;
android.widget.AbsoluteLayout.LayoutParams;
android.widget.AbsListView.LayoutParams;
android.widget.LinearLayout.LayoutParams;
android.view.ViewGroup.LayoutParams;
android.app.ActionBar.LayoutParams;
android.support.v4.view.ViewPager.LayoutParams;
android.view.WindowManager.LayoutParams
Upvotes: 1
Reputation: 221
I had the same problem. But this should definitely work, just need to check what kind of LaoutParams you are setting. I had the same problem because I am using FrameLaoutPrams instead LayoutParams. I needed to set it like this :
android.widget.FrameLayout.LayoutParams params = new android.widget.FrameLayout.LayoutParams(width, height);
surface.setLayoutParams(params);
Upvotes: 22
Reputation: 6691
setLayoutParams(new LayoutParams(width,height)); i hope this will work
Upvotes: 2