Add TextView objects to SurfaceView
Is开发者_开发技巧 it possible to add Textview objects to SurfaceView through canvas or some other way?
You should take a look at drawPostText
function.
You can do it by passing a reference of your Activity to your SurfaceView by Application class or by public member of your Activity. For example my Solution:
I created my surfaceview in RelativeLayout and add there textview also.
<RelativeLayout ....> <com.package.my.MySurfaceView android:....... /> <TextView android:id="@+id/textId android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout>
In MySurface:
TextView tv=(TextView)MyActivity.MyAct.findViewById(R.id.textId); tv.offsetLeftAndRight(offsetX); tv.offsetTopAndBottom(offsetY); tv.setText("Your Text Here");
精彩评论