Reputation: 25
I am making a game and I don't want the whole canvas to occupy the screen. Is there a way on how to put my class extending SurfaceView into xml? I want to put it to xml so that I can adjust the position and size of the SurfaceView on the screen.
Upvotes: 0
Views: 37
Reputation: 1632
in src:
public class MySurView extends SurfaceView {
public MySurView(Context context) {
super(context);
}
// you must overide this constructor
public MySurView(Context context, AttributeSet attrs) {
super(context, attrs);
}
}
in xml:
<package.name.MySurView
android:id="@+id/surview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</package.name.MySurView>
Upvotes: 1