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.

Android :: Gradient drawn on Canvas looks banded / What to fix


Android :: Using Linear Gradient As Background Looks Banded / Reduce This "behavior"?

May 28, 2010

I'm trying to apply a linear gradient to my ListView.
This is the content of my drawable xml code...

So I apply it to my ListView with:

android:background="@drawable/shape_background_grey"

It works but it looks very "banded" on emulator and on a real device too.

Is there any way to reduce this "behavior"?

View 2 Replies View Related

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 :: 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.

View 1 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 :: 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 :: Multiple Gradient Xml ?

Jul 23, 2010

Is there a way to have 2 gradients in a drawable xml using either a <layer-list> or <shape> or some combination of them?

View 1 Replies View Related

Android :: Get Rid Of Gradient At Top Of An Activity?

May 28, 2010

How can I get rid of the gradient at the top of my screen (the very top of the blue in the screenshot below... below the notification bar)?

View 1 Replies View Related

Android :: PNG 24 With Gradient / Not Showing Correctly

Jun 5, 2009

I have a LinearLayout and I am setting a Background image. I am using a PNG24, and the image has a gradient in it. When I see the image on the computer the gradient is perfect, but when I see it on the emulator or on a real phone, some colors are lost and I see only like 10 colors, so I see lines and not a perfect gradient. Is the emulator 'compressing' the images? Should I make them in other format?

View 3 Replies View Related

Android :: Alpha Gradient On Bitmap Of PNG

Dec 11, 2009

I'm trying to apply an Alpha gradient to a bitmap that I've created from a PNG. I want the image to be opaque at the top and fade to transparent at the bottom. I know this can be done be using getPixels and setPixels for Bitmap and iterating through each row of pixels in the Bitmap and setting the alpha values accordingly, but i was hoping there was a slightly neater way of doing this. I have been looking at the LinearGradient Class and using a Porter Duff transfer mode, but i don't seem to be having much luck with this. It seems that my source image is lost when i apply the Shader to the drawable. Anyone have any tips on how i might apply an alpha gradient to a bitmap?

View 2 Replies View Related

Android :: Smooth Gradient On Different Devices

Jul 26, 2010

In my app i have gradient as drawable which i am using as background and i want it to make it look as smooth as possible. After googling and trying by myself i came up with the following. On nexus one if you call only setDither(true) your gradient is still banding so you have to set PixelFormat like this Window.setFormat(PixelFormat.RGBA_8888). But on the other side G1 does not support RGBA_8888 so calling it make the gradient even uglier than before so Window.setFormat(PixelFormat.RGBA_8888) will not work well on devices that don't support it.What is the correct way smooth my gradient on all devices on which my app will run.

View 1 Replies View Related

Android :: Gradient Image Is Displayed Incorrectly

Sep 21, 2009

I have got another mysterious issue. So, I am setting a background image for LinearLayout. This image contains gradient. Don't know why, but after I launch application the image appears to consist of several parts that actually form "smooth transition" of gradient, and that's why it seems that background image is not a gradient.

View 1 Replies View Related

Android :: Gradient Banding On High DPI Devices

Nov 2, 2009

I've been looking at some issues with the background of our application, particularly on high-density devices (240 dpi, 480x854). I managed to eliminate banding on existing devices (i.e. G1/G2, 160 dpi) by applying the android:dither="true" attribute to our nine-patch image, which is a 1x480px PNG with no noise added. Looks great. However, if I use the same image on a higher resolution device, the banding is pretty nasty looking. Same happens regardless of whether I use a shape+gradient, a noisy nine-patch PNG, or an android:dithered nine-patch PNG -- even if I create an 854px-tall image. Is the use of gradients going to become a problem on high screen density devices, purely because of the display colour depth, or is there any way to solve this?

View 5 Replies View Related

Android :: How To Add Padding To Gradient <shape> In Phone

Oct 25, 2009

I have a shape with a gradient that I'm using as a divider between ListView items. I've defined it as follows:

<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<gradient
android:startColor="#ccd0d3"
android:centerColor="#b6babd"
android:endColor="#ccd0d3"
android:height="1px"
android:angle="0" />

</shape>
I would like to add 6 pixels of padding on either side of the gradient, so that it doesn't extend from edge to edge of the screen.

However, no matter where I put an android:left="6px" and android:right="6px", it doesn't seem to take effect. I can put it in the <shape> element, the <gradient> element, or in a separate <padding> child of <shape>, and it doesn't change anything.

How can I add padding on the left and right of my list divider?

View 2 Replies View Related

Android :: Gradient Styles - Not Working On The Outer-most LinearLayout

Aug 10, 2010

In my Android application I've hidden the default title bar, introduced a TabView and added my own titlebar under that TabView's tabs. At the moment, I'm using the ?android:attr/windowTitleStyle style which makes my new titlebar look gray and gradient. It looks pretty good, but my screens are looking pretty grayscale. I'd like to spice things up a bit by making this titlebar a different color gradient.

What am I looking at here? Creating my own image and using it? The ?android:attr/windowTitleStyle style seems to expand depending on the height of your custom titlebar; so I'm not sure it's actually a single image.

I've attempted to throw a LinearLayout over it with a bit of translucency (ex: making the color #800000FF), but the gradient style I have behind this LinearLayout disappears.

Update:

Per my answer down below, I've figured out that I can create an XML file that defines a gradient and use that. It works fine inside a LinearLayout (titlebar_gradient) I have on my layout. However, it is not working on the outer-most LinearLayout (background_gradient). Could someone tell me why? As I understand it, the ListView should be transparent...

code:...............

View 1 Replies View Related

Android :: Way To Make Custom Seek Bar Having Color Gradient?

Feb 15, 2010

I want to make a custom seek bar having color gradient as shown in the below image URL.

View 6 Replies View Related

Android :: Fill A Path In Droid With Linear Gradient?

May 14, 2010

Given a closed Path object result is like this: http://www.tutorialguide.net/images/adobe_photoshop/0043/001.jpg. Although that is a rectangle I'm looking for something which works with any closed Path.

View 2 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 :: Color Banding - Png Resource That Has Gradient Fade-out Alpha

Oct 29, 2010

Seems my original post ("ugly pngs...") somehow disappeared :( nvm.

I have a problem with a png resource that has gradient fade-out alpha.

The png looks great in the emulator, but displays an artefact known as "color banding" (http://en.wikipedia.org/wiki/Colour_banding)

Has anyone surpassed this issue ?

My designer wants to trop a shadow behind his icons, and that's where the bands appear.

What are my options ?

View 13 Replies View Related

Android :: Extend TextView To Allow Drawing Of Text With A Gradient Effect?

Apr 21, 2010

How would I extend TextView to allow the drawing of text with a gradient effect?

View 2 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

Android :: GLSurfaceView Swaps 2D Bitmaps Being Drawn / Cause Of This Can Be?

Sep 8, 2010

I have an application that receives information from a database, and is used to visualize 2D bitmaps onto a GLSurfaceView. The information received will determine the x-position of the bitmap, and which bitmap image to use (there are 4 different bitmaps in my res folder to choose from).

Below are the three classes that are being used. The Activity sets the Shapes objects that need to be drawn by passing an ArrayList to the GLLayer class. This ArrayList is passed to the instance of ShapeStorage class via another setList method. This class is responsible for drawing when they are received.

The problem that I'm having is the following. Suppose I receive one object (let's say that it's a square at it's located at x=1). Some time goes by, and I receive another shape (this time, it's a triangle, and it's located at x=-1). However, when this new shape appears on the screen, the old bitmap's appearance changes to a triangle, and the new one becomes a square. In other words, the objects themselves are at the correct position that they are supposed to be at, but the bitmap being associated with them has changed. Does anyone know what the possible cause of this can be? I'm still a newbie to OpenGL-ES, and while this code looks very convoluted, it just involves setting a bunch of various properties for the View. code...

View 1 Replies View Related

Android :: Sample Code To Draw A Circular Gradient Mask On Bitmap In Droid?

Nov 11, 2010

Is there a way to draw a circular gradient mask on a bitmap in Android? Trying to produce something similar to a foggy window. Click the window and a transparent circle shows up revealing whats behind the window. Prefferably using a gradient so the center of the circle is completely transparent and the further out from the center the less transparent. Is this possible?

View 1 Replies View Related

Android :: Taking Screen Shot Of Whatever Is Drawn On View

Oct 28, 2009

I am trying to take a screen shot of whatever is drawn on my custom view's canvas. The getDrawingCache() call returns null sometimes. Any pointers to what I am doing wrong here?

View 3 Replies View Related

Android :: Why Force Close Before Activity Screen Is Drawn?

Jun 29, 2010

My app keeps force closing before it starts, eclipse returns no errors in my code and my xml is good.

package com.mhe.test.scan;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class main extends Activity {
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button myScanButton = (Button) findViewById(R.id.myScanButton); myScanButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);
} } );
} EditText totalbox = (EditText) findViewById(R.id.totalbox);
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) { if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
// Handle successful scan totalbox.setText(contents)
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel totalbox.setText("@string/bummer");
} } } }
Essentially it is supposed to call zxing Barcode Scanner to scan a barcode on a button click and return the result into an EditText field.

View 2 Replies View Related







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