how to change custom surfaceView width and height

2020-07-05 06:32发布

How can i change custom SurfaceView width and height. is this possible?

标签: android
4条回答
放荡不羁爱自由
2楼-- · 2020-07-05 06:58

This is the right way to do it :

surfaceView.getHolder().setFixedSize(width, height);
查看更多
萌系小妹纸
3楼-- · 2020-07-05 06:59

setLayoutParams(new LayoutParams(width,height)); i hope this will work

查看更多
再贱就再见
4楼-- · 2020-07-05 07:11

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
查看更多
再贱就再见
5楼-- · 2020-07-05 07:12

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);
查看更多
登录 后发表回答