How can I draw a simple shape with shapedrawable?

by Breezy » Wed, 10 Feb 2010 08:29:09 GMT


Sponsored Links
 I've looked for a tutorial on it, but I can't figure out how to do
it...  For starters, and I can dig some more from there, how do I have
a simple program draw a simple rectangle?  Nothing else, no frills,
just draw and display a rectangle?

I was thinking for the layout I would use ImageView, then use
ShapeDrawable from there, but I'm not so sure if that's correct.

--



How can I draw a simple shape with shapedrawable?

by Breezy » Wed, 10 Feb 2010 08:48:00 GMT


 Hmmm, still a little confused...  Are you saying to utilize the
ImageView, but draw on it as if it were a canvas?

On Feb 9, 6:31pm, Jason Proctor <jason.android.li...@gmail.com>


> >


Sponsored Links


How can I draw a simple shape with shapedrawable?

by schwiz » Wed, 10 Feb 2010 09:02:56 GMT


 You make your own class that inherits from View and in the onDraw
method you call canvas.drawCircle, drawLine, drawPath, etc






> > >



How can I draw a simple shape with shapedrawable?

by Breezy » Wed, 10 Feb 2010 10:56:31 GMT


 Okay, I see what you're talking about, but I guess my question is how
do I put that into my ImageView that's in my XML file?





> > > >



How can I draw a simple shape with shapedrawable?

by schwiz » Wed, 10 Feb 2010 13:06:26 GMT


 You need to override the constructor that has the attributes argument,
and then you just treat it like any other view in the xml file.  like
<your.package.here.customshape android:layout_width="100dip" etc />






> > > > >



Other Threads

1. Cannot get versionName when it set with string reference

Hi, all

I've read the android document and it say that <manifest>'s
android:versionName can be set with string reference. but when I set
it as following:

android:versionName="@string/version"




<string name="version">1.2.7</string>

and try to read it by code:

            PackageInfo pinfo = getPackageManager().getPackageInfo
(getPackageName(), 0);
            return pinfo.versionName;

I got a null string.

but it can be read when I use raw-string:
android:versionName="1.2.7"

How can I get the correct versionName when it used reference? thanks.

--

2. Phoen application integration

Hi,

I am currently designing a VoIP application for the Android platform.
One requirement is the integration with the Phone application but
unfortunately the only hook available seems to be the
ACTION_NEW_OUTGOING_CALL intent.  What would be a good way to have a
better integration?  I am open to any suggestion, from rewriting the
Phone application from scratch to contributing modifications to the
Android platform, as long as it permit to distribute my application
through the Android Market.

Thanks.

-- 

3. NDK for SDK 2.0.1?

4. GLSurfaceView.Renderer render rate

5. Market Support Questions From Users/Buyers

6. How can I alway instantiate my ContentProvider

7. new sdk requires versionCode bump to install?