About set background

by Bill.Tsao » Wed, 14 May 2008 03:17:13 GMT

Sponsored Links
 Dear all:

When I set a graph to be background in "TextView" and "Button" ,

I found that it was stretch in "TextView" and it was its original

I have three questions:

1. Does " set background function " do the different things in that
two different
    object ?

2.Can I decide the graph position in my button?

3.Can I tile my graph in my button?


About set background

by Rui Martins » Wed, 14 May 2008 13:15:56 GMT

 I had some problems with setting background too, namelly in an
Activity !

The background image is always stretched or compressed in order to fit
the window.
Besides not having any options, for tiling, stretching, etc. the real
problem is that this is always done in every redraw.

What I mean is, if for example, you have a larger image for the
background, in order to cover the case for larger screens (yes I know
you can define one for each supported screen size in resources), it
will autoresize the image on every redraw of the activity window! And
this is slow as hell !
if instead you just place your background image on the top left, using
a drawable, it's many times faster, since now, it will clip the image
correctly (no stretching done), and so resizing of image is avoided !

Even if background resizing is a wanted feature, the resize result
should be cached since the background (or it's size) won't change that
often, at least not on every redraw !

It would also be nice to be abel to control the background drawing
with a Matrix, like everything else in a regular canvas.
Of course a few shortcuts, for stretch, tile, etc, could be defined
using a shader or similar.

About your question, see below.

Not very consistent, but they are on different level contexts.
But a generic solution, like mentioned above would be better.

Yes it does, in this case, a method in one object, doesn't have to
have the same functionality of another one, but it would be nice if it
was similar, contextually.

I think not !
By default, background will cover the entire button area.
You can however edit you image, and eventually make it transparent in
some places, if required using a PNG image file.

As far as I know, backgrounds have no fancy features, unlike the rest
of the 2D API.
So, if you want to tile an image, increase your image size, and edit
it to look as if it was tiled!
(of course, you will loose any size benefits that real tilling would
have provided)


Sponsored Links

Other Threads

1. Layout question - how to replicate what the iPhone does...

Hi there,

I have an application that consists of a series of tasks, and I'm
struggling to replicate a user experience that is simple to implement
on the iPhone.

In the abstract: on the home screen, I'd like there to be a list of
four tasks, of various kinds.

-- Two will invite the user to click on them, with an arrow. When they
are complete, they show a tick.
-- One task is dependent on the others, so it will be greyed out until
the others are completed. Then it looks like the others.
-- Another task runs in the background, so it has a progress icon
running until it's finished, instead of an arrow.

To show what I mean concretely, this is the application that I'm
trying to replicate - check out the home screen: 

How would I even start to create a home screen that looks like this in
Android? Essentially I need clickable areas with text and icons.
Buttons can't have images attached, nor can they be greyed out. Maybe
a List... but you can't attach checkboxes or progress indicators to
individual items. Is a series of WebViews the best way?

Or should I use something radically different like a TabWidget? I do
like the layout here, though...

Can anyone help? I'm really struggling to know what to do!

Thank you for your help!


2. Handler for map panning

I have searched this group extensively and have not found the answer
to my issue.

I have a lot of server data being loaded into overlays and I want to
create the overlays as the user pans.  Ideally it would wait for the
user to stop panning before it started loading the data.

What is the best practices procedure for determining if the map has
changed location or zoom level?  I was looking for something along the
lines of onLocationChanged() for MapView or onPan() but I have not
seen anything like that.

Do I just need to set up my own parameters and Override onDraw() in
the MapView and in that method run tests to see if the map has
changed?  This idea seems like overkill and would lead to overzealous
server hits.

Anyone have a better idea?


3. Making VideoView play automatically

4. Is anyone else getting bored of announced product releases that don't materialise ...

5. cupcake 1.5 r1 surfaceCreated is not called!!!

6. TabHost launching Intent multiple times

7. HTC Magic release in Spain, with apps on SD?