Android :: Measuring Text Height To Be Drawn On Canvas

Sep 6, 2010

Any straight forward way to measure the height of text? The way I am doing it now is by using Paint's measureText() to get the width, then by trial and error finding a value to get an approximate height. I've also been messing around with FontMetrics, but all these seem like approximate methods that suck. I am trying to scale things for different resolutions. I can do it, but I end up with incredibly verbose code with lots of calculations to determine relative sizes. I hate it! There has to be a better way.

Android :: Measuring text height to be drawn on Canvas


Android :: Measuring Text Width To Be Drawn On Canvas

Jul 15, 2010

Is there a method which returns the width ( in pixels ) of a text to be drawn on an Android canvas using the drawText() method according to the Paint used to draw it.

View 1 Replies View Related

Android :: Gradient Drawn On Canvas Looks Banded / What To Fix

Sep 23, 2010

I have a gray gradient drawable (png image in res/drawable). If I draw it on a white Canvas it looks banded (not smooth). If I put the gradient on white background in GIMP, and then draw this drawable on the Canvas, it looks great. What's the problem? I tested this on Nexus One. Calling setDither(true) on the drawable has no noticable effect.

View 2 Replies View Related

Android :: Rotate Particular Image Among Multiple Images Drawn To Canvas In Droid

Jun 16, 2010

I need a small help on rotating one image around its center of axis among multiple images which are drawn to canvas in android.

I am loading images to canvas like below.

canvas.drawBitmap(mMachineBackground, 0, 0, null);
canvas.drawBitmap(mMachineRotator, 0, 0, null);

I want to rotate only the second bitmap around its center of axis instead of rotating the entire canvas(which includes first bitmap also).

View 2 Replies View Related

Android :: Show Shadow For Text Drawn On Google Map

Jun 7, 2010

In my map application I am using overlay items and texts. I need shadows for both. For overlayitems I am able to display shadows. How to show shadow for the text drawn?

View 4 Replies View Related

Android :: Draw Text On Canvas?

Oct 28, 2010

i'm trying to develop a simple pie chart class for android. For now, it can take a map of labels and values and draw the pie chart. I'm yet to add the legends for the pie, which is where i need to place the texts near small rectangles on the screen corner. Any help appreciated, since i'm new to Android dev.

View 1 Replies View Related

Android :: Using StaticLayout With Canvas To Draw Text

Feb 4, 2010

I have figured out the static layout this far, but I have no idea how to make it display my text anywhere else but in the top left corner. StaticLayout layout = new StaticLayout(text, getTextPaint(), 140, android.text.Layout.Alignment.ALIGN_CENTER,(float)1.0, (float)0.0, true); layout.draw(canvas);

View 2 Replies View Related

Android :: Not Getting Complete Text While Animation On Canvas

Nov 16, 2010

I want to get an animated text in Android where it should run from left to right on the screen.

Eg: I want to get this text. private static final String QUOTE = "Nobody uses Java anymore. It's this big heavyweight ball and chain.";

running from right to left using animation.

However, this text gets truncated to "Nobody uses Java anymore. It's" in Portrait mode and to "Nobody uses Java anymore. It's this big heavyweight" in landscape mode.

This is the code that I have used:

CODE:......................

View 1 Replies View Related

Android :: Increase Height Of Text View On Run Time

Aug 27, 2010

I have a TextView and I want to increase its height on runtime.I have used android:layout_height="wrap_content" but it did not gave me the desired result.I'm using a Relative Layout.i get text through edittext and i want to set it on textview.When i do this it shows only one line, and when i click on edittext it get expanded and full message is shown.

View 2 Replies View Related

Android :: How To Write Centered Multi Colored Text To Canvas

Sep 10, 2010

I am writing to a canvas from a thread.

public void draw(Canvas canvas) {
Paint p = new Paint();
p.setAntiAlias(true);
p.setTextSize(30);
p.setColor(Color.WHITE);
p.setTextAlign(Paint.Align.CENTER);
canvas.drawText("Centered", xCentre, yCentre, p);
}

My problem start when I have a multi colored SpannableStringBuilder which I want to write to the canvas, and I have no idea how to do this. SpannableStringBuilder has a drawText() method which I have been unable to use. Or is there some other method to write a string to a canvas where some of the letters have a different color?

View 1 Replies View Related

Android :: Drawing Text In Custom View Using Canvas.drawtext

Jul 19, 2010

I am drawing text in my custom view in android using canvas.drawtext. i need to change back color, and want text right aligned. for example i want to print the text in a 10, 10, 100, 20 rectangle of color yellow and text color red and right aligned. how can i do that ?

View 2 Replies View Related

Android : Min Height Fill_parent And Height Wrap_content In ScrollView - Or Just The Email App Compose Layout's Code

Oct 7, 2010

If I have the following:

CODE:..............

How can I get the body (second EditText) to fill the rest of the screen, but still have the scrollview kick in when the contents of the body are too long? Like a height="wrap_content" and minHeight="fill_parent"

layout_height="fill_parent" seems to not do anything if you put them in a scrollview

A working example of what I want is the email app compose window

I tried this and the EditText elements act like they are wrap_content and no filling is happening. Just scrolling if you type enough

CODE:...................

View 2 Replies View Related

Android :: When Listview Height Is Higher Than Screen Height It Goes Under Button

Oct 28, 2010

This is my layout that suppot delete from listview ,the problem is when listview height is higher than screen height it goes under the button , so need a solution for avoding it

View 3 Replies View Related

Android :: Drawing Word-wrapped Text At Arbitrary Position On A Canvas

Jan 16, 2010

I believe I know the basics and have successfully published a nice graphical game (Tairu). I know about inflating an xml layout and instantiating views that work.

For my current project, I really just want something similar to the Windows 'DrawText' function where it will draw a bit of a text inside an arbitrary rectangle of the surface, and do word wrap within that rectangles boundaries. That's what I really WANT, but I can't find any form of drawText that will wrap.

So, while that's what I WANT, I can accept the thought of programmatically instantiating a TextView (which wraps beautifully). But I still need to be able to provide the rectangle, which is highly dynamic. (which is why I want to call a form of drawText inside of my onDraw method). In this particular case, I have something which is static to a particular view instance (I mean, the View becomes visible, the position is set, and does not change after that. but the text position is dependent on game state and cannot be pre-determined inside an XML layout). So in this one case, I could afford the expense of runtime recalculation of the layout when the view is displayed.

OK, fine. So I do something like this:

CODE:......

Pretend you didn't see 'AbsoluteLayout' there, I am desperate and have tried all possible layout classes

main_frame is defined in my main XML layout (it is the outermost layout, fills the parent, and, as I said, I've tried all the offered layouts)

With this code, the textView appears, but along the top of the layout, and not using the width I provided either.

Adding, out of desperation.

CODE:.......

makes no difference. In fact, so far, NOTHING has made any difference. So I thought, ok, while this seems like a useful thing to be able to do, I can accept if it can't. I accept that it is impossible to provide dimensions in advance and that you have to override the measure and layout callbacks then requestLayout and in your overrides, force the final layout for the TextView.

Of course, that is completely unacceptable for my FIRST desire (a drawText that wraps to a rectangle, called from onDraw as needed). But the point is I feel something like that OUGHT to work, and it doesn't, so clearly this is MY fault.

Getting back to what I WANT, I guess I can do it myself by repeated calls to measure text and parsing the string for spaces until I get the N characters which fit on the first line, then repeat for additional lines, calling a normal drawText for each line (and using textMetrics to determine the vertical offset to the next line.)

But why wouldn't that method already exist? I promise not to fill the screen with a zillion calls, and/or to cache pre-rendered text on some bitmap somewhere if antialiased drawText is too expensive to repeat frequently.

View 7 Replies View Related

Android :: How To Get Button's Height To Match Another Element's Height

Nov 15, 2010

I want to put a button next to a EditText and I want their heights to match.For example, from the built in Android browser:

The Go button is the same height as the EditText field.I know I could wrap both these views in a parent layout view, and set both of their heights to fill_parent, and that would make them match.However, I would like to do this without having to give the layout a static size.I would rather have the EditText take whatever height it needs based on the font size and then have the button next to it match whatever height that might be.Is this possible with an xml layout?

View 2 Replies View Related

Android :: Reset Canvas - Draw A New Bitmap Into The Canvas

Jul 7, 2010

My loadMap() method generate a canvas.throwIfRecycled exception when i try to load a new map.
When i start the game, the initial map loads and work fine though,
its only when i try to load a new map that i get the exception ..

How can i "reset" canvas and the bitmap i use to draw into, so i can startover fresh with them ?
here's what i use to create and draw my maps:

CODE:.........

So basicaly once i created and used picDest and canvas, i cannot figure how to reset it all for when i want to load a new map..

View 1 Replies View Related

Android : RelativeLayout Height Not Following GridView Height

Aug 28, 2010

I am having problem with a GridView within a RelativeLayout, which is again within a ScrollView. The problem is that the height of the RelativeLayout is not following the height of the contents of the GridView. When there are more than one rows, the GridView is clipped and a scrollbar appears, which is undesirable. I have tried to illustrate my problem using an screenshot from the Android hierarchy viewer. You can see how the red RelativeLayout box has clipped the second row of the GridView. I am pasting the XML layout of the page (page.xml) and the individual grid item (griditem.xml). I have used the following code to inflate the grid items in the gridAdapter code:

CODE:.................

What I should do to have the height of the RelativeLayout follow the full length of the gridView?

Here is the screenshot: http://tinypic.com/r/98rs4n/4

View 1 Replies View Related

Android :: Measuring A View Before Rendering It

May 13, 2010

I need to find out how big a view will be after attaching it to its parent.I have overridden this method: Do you think there is a way to get this information before rendering the view itself? Basically I need to know the actually size before attaching it and not attach the view at all if it would take more certain amount of space. Code...

View 2 Replies View Related

Android :: Measuring Real Phone Signal Strength On Mobil?

Dec 4, 2009

I want to programmatically measure the phone signal strength in a mobile phone. I don't actually care about the mobile phone or the programming environment: It can be based on android or windows mobile or even J2ME and can be from any manufacturer (please no iPhone). However, it needs to be a real, commercial mobile phone and not a special measurement device. This problem is not as easy as it seems with a first look. I am aware that there already exist a number of methods that claim to return the phone signal strength. Some of these are:

SystemState.PhoneSignalStrength for WM6 RIL_GetCellTowerInfo for WinCe (dwRxLevel member of returned RILCELLTOWERINFO struct) android.telephony.NeighboringCellInfo.getRssi() for android

The problem with the above is that they only return a few (under 10) discrete values, meaning that, for instance, the return values of SystemState.PhoneSignalStrength can only be translated to (for instance) -100 dbm, -90 dbm, -80 dbm, -70 dbm and -60 dbm, something that is not useful for my application, since I'd like to have as much precision as possible. It doesn't matter if there is an undocumented solution that only works on only one phone

View 4 Replies View Related

Android :: Default Measuring Units Pixels / Density Independent

Aug 13, 2009

in xml file we can define measuring units along with the values. If I want to set some property through code it only takes "int" value. What is the default unit for this int? px(pixels) or dp(density independent pixels) ?

View 7 Replies View Related

General :: Measuring Battery By MV?

Mar 13, 2012

I have a 3500 mAH battery that refuses to calibrate.... Anyways when I use Battery Calibrate, its says my current mV is 3643, I know that isn't full, but my battery percent says 23% and that is much to low for 3643mV! My co-worker said to divide 3643 by 4200 (Full charge IIRC) and that is my battery percent. I think there has to be a better way...

View 1 Replies View Related

HTC Incredible :: Measuring Battery Life

May 24, 2010

Just tested my battery (stock) vs my new battery (1750). I got about 4.5 hours running my stock battery down to 25% or so and I'm now at about 6.5 hours running the 1750 down to 27%. When people talk about measuring battery life are they talking about 100%-0% or are they just talking about just 100%-20% or so. This is really the only usable battery range because the radio turns off somewhere under the 20% point. I'm also thinking that my Seidio battery isn't working properly. It was kind of bent out of shape when I got it and felt pretty filmsy. I decided to give it a try but now I'm kind of thinking about returning it in the hopes of getting better life out of a new one.So two questions here what range are you all measuring your battery life through? and any chance that Il' get more life out of a new battery?

View 16 Replies View Related

Retrieve And Set ListView Items (cells) Height Depending On ListView Height

Apr 4, 2012

I have some class LoginActivity.java. In the onCreate method I retrieve ListView:

ListView list = (ListView)findViewById(R.id.snListView); then:

list.setAdapter(adapter);

In addition there are login.xml layout - there are:

<ListView
android:id="@+id/snListView"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
and sn_row.xml:

[Code]...

At the moment I have cell's height 100dp, I need that cell's height will depend on device, I mean I have here 5 cells showing at login screen in ListView and I need that these 5 rows will fit the ListView (cell's height = ListView's height/5).

View 1 Replies View Related

Android :: Overlays Drawn On The Map

Jul 17, 2010

What I am trying to do - I am continuously getting a stream of lat/lng positions, I want to move a overlay item dynamically on the map based on the lat/lng in the stream. I am displaying the location of moving object dynamically on the map

I am putting my whole code in a while(true) loop and trying to read the stream every 5 seconds and refresh the overlays on the map. But overlay items are not shown until the function (either oncreate, or any onclickeventhandler etc) is completed. For example, test code, I am adding a single test overlay item when ever the user clicks on a button. If I put a wait(2000000) "after" I add overlays and invalidate the map, the overlay is not displayed until the time has elapsed and the function is completed.

View 5 Replies View Related

Android :: OpenGl Drawn Something?

May 10, 2010

glReadPixels is too slow, so I need another way. Without testing object by object, Is there any other way?

View 7 Replies View Related

Android :: Use SurfaceView Properly , Nothing Is Drawn

May 31, 2009

I had it working with a normal View but that is to slow. I was told to use SurfaceView but can't figure out how to use OnKey with it and if I should use onDraw or draw? And how do I pass stuff to draw? does it happen automatically? code...

View 3 Replies View Related

Android :: Does A RemoteView Get Drawn On Screen?

Apr 28, 2009

From the javadoc of RemoteView, it said " * A class that describes a view hierarchy that can be displayed in another process."

But unlike View class, RemoteView does not have a 'draw(Canvas canvas)' method. Can you please tell me which method of RemoteView causing its layout to be drawn on screen?

View 2 Replies View Related

Android :: Able To Get Current OverlayItem Being Drawn

Jul 8, 2010

I want to be able to get some reference to the curent object being drawn. code...

Above is my draw method and I want to extend the draw method to write the title underneath each item for example. This would require the .getTitle() method from the OverlayItem. Possibly some tracking of objects outside of this method but not sure where to put it....

View 1 Replies View Related

Android :: Implement Dynamically Drawn Content?

Feb 2, 2010

Based on the limitations of RemoteViews, it looks to me that the appropriate way to get it actually drawn on the screen is to use an ImageView in the actual layout, then when it is updating, create a ShapeDrawable or two and draw them onto a newly created Bitmap. Then, set that Bitmap as the source of the ImageView. There is Something about that process that I'm just not grokking, though. The following is the code I tried to use to update the widget. I get nothing drawn on the screen at all. The ImageView has a placeholder image just set by its src property. When I don't run the code to update it to my drawing, the placeholder image stays in place. So, I know this code is doing something, just obviously not the right thing.

RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
Bitmap bitmap = Bitmap.createBitmap(100, 100, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);

ShapeDrawable drawable = new ShapeDrawable(new ArcShape(0, 360));
drawable.getPaint().setColor(0xffff0000);
drawable.getPaint().setStrokeWidth(5.0f);
drawable.setIntrinsicWidth(100);
drawable.setIntrinsicHeight(100);
drawable.draw(canvas);

views.setImageViewBitmap(R.id.ImageView01, bitmap);
appWidgetManager.updateAppWidget(appWidgetId, views);

I knew it couldn't be that easy. So, am I even heading in the right direction? Update Ok, maybe that was too much information. The question I'm really trying to ask is this: If I want to draw shapes on a widget, should I use an ImageView and create a bitmap from my ShapeDrawable or is there more appropriate way to draw into a widget where it is constrained by RemoteViews?

View 7 Replies View Related

Android :: Get Bitmap Data Before It Is Drawn On Screen

Feb 22, 2010

To any normal android Widgets based on View( Button ,TextView ...), I wanna manipulate the bitmap data before it is drawn on screen. I have tried the onDraw(Canvas canvas) method, But when the programe hit the onDraw(Canvas canvas) method, I think the bitmap has already been drawn to screen.

If there is any way that I can get the bitmap data before it's drawn to screen, so I can prevent it from being displayed , but grab the data, put it on the intent for some further use?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved