2012-03-20 101 views
0

我正在制作游戏,我不希望整个画布占据屏幕。有没有办法让我的类扩展SurfaceView到XML?我想把它放到xml中,以便我可以在屏幕上调整SurfaceView的位置和大小。自定义查看到xml

回答

1
在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); 
    } 
} 
在XML

<package.name.MySurView 
    android:id="@+id/surview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
</package.name.MySurView> 
+0

谢谢ethan_liou :) – 2012-03-20 16:50:29