Search in This Blog

change SurfaceView height width


change SurfaceView height width in android.
You are using SurfaceView to open camera in Android. and want to set it's custom height and width. So How can you change SurfaceView height width?


To change SurfaceView's custom height and width use "android.view.ViewGroup.LayoutParams"
There are subclasses of LayoutParams for different subclasses of ViewGroup. For example, AbsoluteLayout has its own subclass of LayoutParams which adds an X and Y value.  By this you can change X and Y of SurfaceView 


Use below  code:
android.view.ViewGroup.LayoutParams avvglp = surfaceView.getLayoutParams();
avvglp .width=300;

To See more here: