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

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?


Thx,
--~--~---------~--~----~------------~-------~--~----~



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.




Yes
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. Creating a custom Calendar desktop widget - problems running default calendar projects

Hello.

I want to extend the default Calendar desktop widget, to make it more
flexible.

I have 1.5 SDK downloaded, and (after assorted problems) I have
Eclipse updated with ADT 0.9.1

I have tried to git-clone on the two calendar projects within the
repository:
git://android.git.kernel.org/platform/packages/apps/Calendar.git
git://android.git.kernel.org/platform/packages/providers/CalendarProvider.git

However, whilst git seems to check these out ok, attempting to just
run the projects in Eclipse results in a huge variety of errors:
---
Description     Resource        Path    Location        Type
Class com.android.calendar.CalendarTests does not exist
AndroidManifest.xml     Calendar        line 99 Android XML Content Problem
AccountMonitor cannot be resolved to a type     CalendarActivity.java
Calendar/src/com/android/calendar       line 157        Java Problem
---

Does anyone have any ideas or suggestions on what has gone wrong or
what I need to do to get things working?

Thanks,

Peter

--~--~---------~--~----~------------~-------~--~----~

2. To Do List Example Crashed Eclipse

I have been progressing through the To Do List example from the book
"Professional Android Application Development". At each stage of the
example I would run the app without any major problems. Then after the
final stage I ran the App. At first it worked including the "remove
item" feature. Then it crashed a few times. After reloading it worked
but not the "remove item" feature. Then I restarted my computer.  Now
Eclipse won't load it or even load another test app that I had
written. The name of my app is mmc2android4. When I try to run it in
eclipse I get the following messages-
[2009-05-18 21:34:02 - mmc2android4] WARNING: Unknown device API
version!
[2009-05-18 21:34:02 - mmc2android4] Failed to upload mmc2android4.apk
on device 'emulator-5554': Unable to open sync connection!

Help please

Mike

--~--~---------~--~----~------------~-------~--~----~

3. Spinner hint

4. How to use onCreateOptionsMenu,onOptionsItemSelected&onPrepareOptionsMenu?

5. Dynamically change ListView doesn't work

6. Listview with multiple coulmns

7. getting device offline when trying to debug on my phone