How to draw text in rectangle

by wr1472 » Tue, 04 Aug 2009 23:15:12 GMT

Sponsored Links

I have just started looking at developing for Google Android and want
to draw a rectangle with some text in it that I then want to position
where i want on screen.

I have got as far as drawing a rectangle on screen using a
ShapeDrawable and RectShape I now want to put some text in the
rectangle. How can I best do this? Should I be looking at somehow
adding a textView to the RectShape? Or am i going down the the wrong
avenue completely?

Some pointers would help greatly!



How to draw text in rectangle

by Kent » Wed, 05 Aug 2009 14:41:45 GMT

 I don't know what you are trying to do, but if it's just simple layout
stuff you may be making life more difficult for yourself than
necessary. Try one of these things instead:

a: use a textView and set it's background property (either to a color
#argb or to a drawable). This has limitations, but for a single text
item it should work fine.  Depending on what you want, you can tweak
the layout_width/layout_height parameters to get pretty close. An .xml

    android:id = "@+id/text1"
    android:background = "@+drawable/filename"
    android:textSize = "12pt"
    android:textStyle= "bold"
    android:textColor= "#001"

b: use a layout(relativeLayout, etc) and set it's background/size then
put the textView or anything else you want into it. You could also
leave the background blank and put the drawable into the layout

<RelativeLayout xmlns:android=" 
    android:id = "@+id/container1"
    android:background = "@+drawable/image"
        android:id = "@+id/text1"

There is an awful lot of flexibility, so without knowing what you are
after ... it's hard to say. Probably check the beginners forum at:

Sponsored Links

How to draw text in rectangle

by Yusuf T. Mobile » Thu, 06 Aug 2009 01:26:19 GMT

 ent is right, the easy way is with TextView, but if you want the
flexibility of placing your text and rectangle anywhere (like with a
bouncing text+rectangle on the screen), then the Canvas class has
drawText() and drawRect().

Yusuf Saib
T Mobile stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.

On Aug 4, 11:41pm, Kent <> wrote:

Other Threads

1. About textfile


   Can anybody please tell me,In the path
(data/com.IW.sample/files/judy.txt),i cant find the above path where can i
find these path?

Thanks & Regards

Analdin Judy.M
Knowledgeware. Beyond Multimedia
Chennai | INDIA
M: +91.98416.64705

"The information contained in this e-mail (including any attachments) is
intended by InfoWave for the use of the named individual or entity to which
it is directed and is CONFIDENTIAL or PRIVILEGED. If you have received this
e-mail (including any attachments) in error, please do not review, disclose,
disseminate, distribute or copy this e-mail and attachments. As Electronic
and Internet communications can be interfered with or affected by viruses
and other defects, please scan this message and any attachments"


2. NullPointer exception while creating Object

          I am creating the object of the radiobutton but i am getting
nullpointer exception And also tell me how to use RadioGroup .
here is my code

public class RadioItem extends LinearLayout
        private RadioGroup mradioGroup;
        private RadioButton[]  m_radiobutton ;
        public RadioItem (Context context)

        public RadioItem(Context context,String title[])

        LinearLayout.LayoutParams layoutParams =  new
        layoutParams.setMargins(1,1, 1,1);
        mradioGroup = new RadioGroup(context);

                for(int i = 0 ; i < title.length ; i++ )

                        m_radiobutton[i] = new RadioButton(context);  // here i 
am getting
null pointer exception.




3. using mysql

4. HELP! R.layout.main cannot be resolved error

5. Class loading order, Xml Document.NormalizeDocument method

6. Interface theme

7. Calling a stored procedure and committing