Why not put a Layout around your bouncing ball view and then put a textview inside the layout?
On Jan 13, 5:42 am, Abolfoooud <fcheh...@yahoo.com> wrote: > Any insight on this?! > > On Jan 11, 5:14 pm, Abolfoooud <fcheh...@yahoo.com> wrote: > > > > > Hi, > > > I have been trying to find a solution for this for the last 3 days but > > i just failed hit a final answer! > > > I am creating a View-based class where i show a ball bouncing of the > > sides. I use a Timer to control the animation. > > > I want to add a TextView programmatically in my view class. I am > > trying to instantiate an object of TextView with reference to the > > context as follows: > > > public class BouncingBallView extends View > > { > > public TextView textView; > > ... > > > public BouncingBallView(Context context) > > { > > super(context); > > textView = new TextView(context); > > textView.setTextColor(Color.WHITE); > > textView.setText("test"); > > ... > > > } > > > // Keep in mind that this is called periodically by using a Timer > > @Override protected void onDraw(Canvas canvas) > > { > > // This is not drawn > > textView.draw(canvas); > > > // ball drawn correctly > > mBall.setBounds(mX, mY, mX+mBallWidth, mY+mBallHeight); > > mBall.getPaint().setStyle(Paint.Style.STROKE); > > mBall.getPaint().setColor(0xFFFF0000); > > mBall.getPaint().setStrokeWidth(5); > > mBall.draw(canvas); > > mBall.getPaint().setStyle(Paint.Style.FILL); > > mBall.getPaint().setColor(0xFFFFFFFF); > > mBall.draw(canvas); > > > } > > > I am trying to do this programmatically as i am not sure if i can do > > it using xml since i alread have created my custom bouncingballview > > and used it as the parameter for setContentView(). > > > Can any one direct me of how to do this? > > Sorry if this is a trivial question but i am still new to graphics > > handling in Android... i come from Symbian background. If you do know > > of a good introductory article to this topic please share it here. > > > Many thanks in advance > > AF
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en