TransitionDrawable with different sized bitmaps

by Brill Pappin » Fri, 20 May 2011 04:20:29 GMT


Sponsored Links
 I'm using a TransitionDrawable to draw a series of bitmaps in an ImageView.
Every time my scheduled handler ticks over, i replace the bitmaps.

I'm finding that if they are not the same size, the draw splits the 
difference for the second bitmap using the first bitmap (at least I think 
thats whats going on).

I was thinking that I might use two bitmaps there were the same size as a 
base, then draw my actual jpeg's onto those so the TransitionDrawable 
doesn't try and scale them.

Is there a better way to do this?

-- 



Re: TransitionDrawable with different sized bitmaps

by Brill Pappin » Fri, 20 May 2011 12:24:42 GMT


 An update to this problem.
It seems the issue is related to ImageView's automatic scaling somehow.
it *looks* as if the TransitionDrawable needs both images to be the same 
size... or maybe ImageView does it.
The symptom is that it divides the difference in width between the to images 
(i.e. an image in landscape and one in portrait so you get one squashed and 
one stretched).


-- 


Sponsored Links


Re: Re: TransitionDrawable with different sized bitmaps

by Dianne Hackborn » Fri, 20 May 2011 12:36:58 GMT


 The images need to be the same.  Generally widgets don't like nor have a way
to deal with drawable dimensions changing out from under them.







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 



Re: Re: TransitionDrawable with different sized bitmaps

by Brill Pappin » Fri, 20 May 2011 12:46:47 GMT


 The funny thing is how its actually handling it. Both parts of the 
transition are getting scaled.

What i'm doing is cycling through images from the MediaResolver (like camera 
shots) and crossfading between them.
Do you have any suggestions for other ways to do that?

At the moment I'm playing around with creating a "template" bitmap that is 
used to draw everything onto, then give it to the ImageView, but I'm not 
feeling all that good about the solution so far.

-- 



Re: Re: TransitionDrawable with different sized bitmaps

by Dianne Hackborn » Fri, 20 May 2011 15:10:21 GMT


 You could write your own Drawable that keeps its size consistent across the
images and does whatever transition you want.  Or use a ViewFlipper to swap
between ImageViews.







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 



Other Threads

1. help in service

Hi there,

I have been doing with the android for a while, but I am totally confused
with the service part.

I can create a service, start / stop from the activity.

 

I have seen many examples but besides clearing, they have infact confused me
more.

 

But what I need is that the service as response from web request launches a
intent (within the same application package) and bring it to front. Also I
want activity (same application but different from the one that created
service) to get variables in the service or use methods declared in
service..so inshort 2 requirements for now:

1.     Basically how to get the instance of the service from another
activity...

2.     Call the specific activity / intent from the service and getting it
on front.

 

For example, from the server end I may send relogin request, for which the
service will call clear the local login status and show login activity.

So far what I have been able to do is call notification manager..

 

But there must be some other way to sort things.

 

Thanks in advance

 

 

VINEET YADAV

+1   360-215-1917

+1   978-728-9338

http://twitter.com/geniusvineet

http://vineetyadav.com <http://vineetyadav.com/> 

 

 

-- 

2. Display flicker when a video is played

Hi All,

When I play a video file from gallery, before the actual video starts
playing, there is a black screen with a small triangle on the top
right corner appears on the screen. Why does it happen, how can it be
resolved.

When I debugged the code the intermediate screen is launched at this
point:

**************
public static void playVideo(final Context context, final MediaItem
item) {
        // this is a video
        ((Gallery) context).getHandler().post(new Runnable() {
            public void run() {
                try {
                    Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(item.mContentUri));
                    intent.setDataAndType(Uri.parse(item.mContentUri),
item.mMimeType);
->>>                    context.startActivity(intent); //after this
call black screen is launched.
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(context,
context.getResources().getString(R.string.video_err),
Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

*****************************

context.startActivity(intent); //after this call black screen is
launched.

Is it a problem in the framework or application level?

Please give some guidance about how the issue can be solved.

Thanks.

-- 

3. Any Tree (Swing/JTree-like) widget for Android?

4. Custom Contact Fields

5. standard UI style for "there's more..." ?

6. Forcing Sensor Readout?

7. using Linear Layout with Table Row