Postagens

Mostrando postagens de setembro, 2010

Drawing In an Android View

When I was drawing in a view using onDraw method, I noted that if you are drawing a line, the y scale starts at 1px but if you are drawing a text, the scale starts at height of text, i.e. The text have 10px height, you have to specify 10px at y position to display text at top of view. I think the android are drawing the text above the pixel scale. If you specify to draw the text at 1px, it will be drawed starting at -10px. Drawing a bitmap works fine, the top left of the image is x: 0px y: 0px You can test a lot of scales by putting the above code at onDraw event of a view: private void printScales(Canvas canvas){ Rect clipBounds = canvas.getClipBounds(); String clip_bounds = Integer.toString(clipBounds.right)+"x"+Integer.toString(clipBounds.bottom)+ " - "+Integer.toString(clipBounds.left) + "x" + Integer.toString(clipBounds.top); Log.i("clip bounds", clip_bounds); String canvas_string = Integer.toString(canvas.getWidth())

Android ScrollView Problems

I had some kind of problem when using android:gravity="center" in a TextView inside LinearLayout inside ScrollView and using RelativeLayout too, I just find another way to display contents without using RelativeLayout and TextView with android:gravity="center". The problem was aborting program when layout started, I think in "measure" or "draw" internal methods. The layout was working fine without the ScrollView, but when I put it outside the main LinearLayout, I had this problems that was so difficult to find and fix.

My Custom Android View "StarsViewKMB"

Imagem
StarsViewKMB This view created by me, allows to set and display stars rates as showing below: You can enable or disable trackball/touch changes, you can change star type to (leaf, dollar, star), you can allow to cancel (the red icon), you can get and set stars values between 0 and 10, -1 value it's in the cancel case. Currently do not have the option to resize the pictures, has only two sizes of images. Big (to edit with trackball or touch) and small to display the star value. Methods setIconType(int value) Valid values are: StarsViewKMB.ICON_TYPE_STAR StarsViewKMB.ICON_TYPE_DOLLAR StarsViewKMB.ICON_TYPE_LEAF setStars(int value) Valid values are: A number between 0 and 10 that allows to change selected stars, -1 it's a special value when cancel is allowed. setIsDoubleSize(boolean value) True for big icons, false to small icons. setAllowCancel(boolean value) True if allow cancel option, it displays a red icon before stars. False to disable cancel option. setIsEditable(boolean va

About Me

I'm a developer in: Visual Basic, Java, Php, MySQL, MS Access, Excel, Asp, Visual C, QBasic, Ruby On Rails, ActionScript, Flash, CSS, HTML, Javascript. Webmaster, not web designer. Java Android Application that use GPS, Internet Connection, Web format JSON, MVC (Model, View, Controller) in ruby on rails. Image handling, advanced android layouts using images, tabs, images, google maps, custom Views. MIDP Minefield game using high logical programming, Dinamic Array/Draw, handling time, storage data records, sound, images, all game using a customized drawing. Translator, using simple text file data. Desktop Background running program utility for windows/linux. Using HTTP images, http communications, http text parser, xml file parser. File/Folder handling. Visual Basic 6 In this language, I have done the most applications in various areas such as: Internet communications with socket by HTTP Requests, Ftp, SMTP and custom communications IP to IP Image Editor Full text macros, automation