上次说了 如何使用SurfaceView,文章链接:
2、在Activity布局文件中添加SurfaceView和控件
http://blog.csdn.net/dailinqing1984/article/details/47346037
但如何在SurfaceView中添加控件呢?
1、首先,将SurfaceView的构造函数修改为两个参数的
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
}
2、在Activity布局文件中添加SurfaceView和控件
<com.example..MyView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/view"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/textView"" />