Android animated widget homescreen - Android Software Development

Hi,
I was just wondering, is there any way to have an animated widget on the android homescreen, which stays animated and consists of multiple frames? For instance, an animated flash, gif or png sequence?
Thanks

i never used animations on an app, but try it with gifs, or looped zip files, like bootanimation.zip, that creates an animated picture, from multiple files.

ilendemli said:
i never used animations on an app, but try it with gifs, or looped zip files, like bootanimation.zip, that creates an animated picture, from multiple files.
Click to expand...
Click to collapse
And this can be used as a simple widget?

don't know, wait for other posts, you can make a onclicklistener to an image

I'm not talking from experience here, but since widgets update in real time (facebook and twitter for example), there's obviously a method of updating what's displayed so I can't see any reason that you couldn't have an animated widget (other than the usual CPU and battery issues).

maybe develop a service that is constantly pushing messages to the widget? but I suppose this will be a huge battery drainer....

There should be a way to do it. After all, under the "res" folder, there is a supported and standard sub-directory called "anim" that can be used to bring compiled animation files to your app. Look into on the android developer site. I'm thinking this is the way to do it.
Here is a reference from the adroid dev site on using a class called AnimationDrawable:
public class
AnimationDrawable
extends DrawableContainer
implements Animatable Runnable
java.lang.Object
↳ android.graphics.drawable.Drawable
↳ android.graphics.drawable.DrawableContainer
↳ android.graphics.drawable.AnimationDrawable
Class Overview
An object used to create frame-by-frame animations, defined by a series of Drawable objects, which can be used as a View object's background.
The simplest way to create a frame-by-frame animation is to define the animation in an XML file, placed in the res/drawable/ folder, and set it as the background to a View object. Then, call run() to start the animation.
An AnimationDrawable defined in XML consists of a single <animation-list> element, and a series of nested <item> tags. Each item defines a frame of the animation. See the example below.
spin_animation.xml file in res/drawable/ folder:
Code:
<!-- Animation frames are wheel0.png -- wheel5.png files inside the
res/drawable/ folder -->
<animation-list android:id="selected" android:oneshot="false">
<item android:drawable="@drawable/wheel0" android:duration="50" />
<item android:drawable="@drawable/wheel1" android:duration="50" />
<item android:drawable="@drawable/wheel2" android:duration="50" />
<item android:drawable="@drawable/wheel3" android:duration="50" />
<item android:drawable="@drawable/wheel4" android:duration="50" />
<item android:drawable="@drawable/wheel5" android:duration="50" />
</animation-list>
Here is the code to load and play this animation.
Code:
// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
img.setBackgroundResource(R.drawable.spin_animation);
// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// Start the animation (looped playback by default).
frameAnimation.start()
For more information, see the guide to Animation Resources.

demaxmeister said:
Hi,
I was just wondering, is there any way to have an animated widget on the android homescreen, which stays animated and consists of multiple frames? For instance, an animated flash, gif or png sequence?
Thanks
Click to expand...
Click to collapse
did you ever figure out a simple method to creating an animated simple widget? i was just wondering b/c this is something i too would like to have.

I found this on modaco a few days ago:
http://www.youtube.com/watch?v=G-4k62ln4j4
http://android.modaco.com/content/advent-vega-vega-modaco-com/329946/3d-desktop-plugin/#entry1567646
I think it is for a tablet? Is it possible to port?

Animation in widgets is possible, check my widget.

first off, yes animated widgets are possible. second, animated gifs are not supported natively by ImageView.
http://stackoverflow.com/questions/3660209/android-display-animated-gif
however agif is supported by the WebView so you could make a widget that is just a WebView that displays an animated gif.
http://stackoverflow.com/questions/2702860/how-to-make-animated-gifs-work-from-android-webview
it will suffer performance wise but it would work.
or you could just split the animated gif and make an AnimationDrawable
http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html
cheers!

Please try Animated Photo Frame Widget
https://play.google.com/store/apps/details?id=com.hikaru.photowidgetad

Bump.
Year 2016, still can't figure out how to animated widget.
Can somebody help me please? I tried to google for it, but all i got was gif animation loops and animations in progress bar. I want to know how do people animate the widgets like that of MIUI, DU battery saver and other weather widgets. Is there a library to do it?

Related

Mobile shell 2.0 Skins (color wallpaper) + Different layout mods - Have fun!

hey guys, heres some themes. go to the custo icon's thread for how - to
i've also attached an example.
enjoy!
oh yea, ppl it'd be nice if everybady can post ready to go themes here.
so it'd be a sorta skins dl page =)
edit
its now possible to have a new bmp per page. see my post on pg2 for the example file.
heres a lil illustration 2 give u an idea..
nice collection
can you teach us how to apply them out?
thank???????????????????
sure.
unzip the files
and replace the ones in your spb mobile shell folder
Heres one I made quickly, at the moment the full colour screen only appears on MS Professional now screen! I'm still trying to figure out how to get it displayed on all screens!!!
Again credit to asefsef!
i was only jk gfreak lol, its a dirty trick.
btw, full screen pic is confirmed to work on other screens, just copy the separator line into their corresponding xml's and point to that same separator bmp for same walls on the screens.
or, point to a diff set of bmp's for different walls per page
asefsef said:
i was only jk gfreak lol, its a dirty trick.
btw, full screen pic is confirmed to work on other screens, just copy the separator line into their corresponding xml's and point to that same separator bmp for same walls on the screens.
or, point to a diff set of bmp's for different walls per page
Click to expand...
Click to collapse
Thanks got it working on all screens except one the "Classic Now Screen" do you know which xml file I have to edit? I thought it was the xml's time and lockscreen but it not those:-/
Just a quickie!! Could someone post a simple intructional on changing the background pic? I have the icons and (still testing) possible layout I want, but I would like to change my background!! I have a simple pic I would like on all my pages, so any help would be appreciated!!!
asefsef said:
i was only jk gfreak lol, its a dirty trick.
btw, full screen pic is confirmed to work on other screens, just copy the separator line into their corresponding xml's and point to that same separator bmp for same walls on the screens.
or, point to a diff set of bmp's for different walls per page
Click to expand...
Click to collapse
I hate to sound incredibly dense, but what attribute did you set to make the separator point to a different bitmap? Or are you talking about using one of the other separators, and substituting a full screen bitmap for them?
As far as I can tell from the XML, specifying <Point Name="Separator3Y" X="0" Y="0"/> implies that the image will be coming from a specific bitmap.
RoboDad said:
I hate to sound incredibly dense, but what attribute did you set to make the separator point to a different bitmap? Or are you talking about using one of the other separators, and substituting a full screen bitmap for them?
As far as I can tell from the XML, specifying <Point Name="Separator3Y" X="0" Y="0"/> implies that the image will be coming from a specific bitmap.
Click to expand...
Click to collapse
I've got colour background on all screens buy editing xml's time,lockscreen,waether,launcher and spb menu by having this class definition:
<Plugin Class="Spb.LSP.GradBackground" Name="Background">
<Int Name="NoBackgrd" Value="0"/>
<Point Name="Separator3Y" X="0" Y="0"/>
However, except one screen the "Classic Now Screen" don't understand why? I'm sure I'm missing something in lockscreen xml???
gfreek said:
I've got colour background on all screens buy editing xml's time,lockscreen,waether,launcher and spb menu by having this class definition:
<Plugin Class="Spb.LSP.GradBackground" Name="Background">
<Int Name="NoBackgrd" Value="0"/>
<Point Name="Separator3Y" X="0" Y="0"/>
However, except one screen the "Classic Now Screen" don't understand why? I'm sure I'm missing something in lockscreen xml???
Click to expand...
Click to collapse
Right, I also have one image working on all of my screens as well (as far as what you might be missing, I'm not sure, but I do know that whatever is missing will be in lockscreen.xml, most likely in the Detailed layout section).
What my question is, is how asefsef was able to get a different image on each screen.
RoboDad said:
Right, I also have one image working on all of my screens as well (as far as what you might be missing, I'm not sure, but I do know that whatever is missing will be in lockscreen.xml, most likely in the Detailed layout section).
What my question is, is how asefsef was able to get a different image on each screen.
Click to expand...
Click to collapse
ok! here's what i've got in lockscreen xml;
<Layout Name="Detailed">
<Plugins>
<Plugin Class="Spb.LSP.GradBackground" Name="Background">
<Int Name="NoBackgrd" Value="1"/>
<Point Name="Separator3Y" X="0" Y="0"/>
the above class definition works for "Professional Screen Now" however if I do the same for Classic screen under the following class definition:
<Layout Name="Simple">
<Plugins>
<Plugin Class="Spb.LSP.GradBackground" Name="Background"/>
<Int Name="NoBackgrd" Value="1"/>
<Point Name="Separator3Y" X="0" Y="0"/>
not sure whats missing??
and yes I'd also would like to know how asefsef can get different bmp's for screen!
a quick question
gfreek said:
Heres one I made quickly, at the moment the full colour screen only appears on MS Professional now screen! I'm still trying to figure out how to get it displayed on all screens!!!
Again credit to asefsef!
Click to expand...
Click to collapse
do you know how to make it 9 tab selection?
and how have you made it as 4 as you can see there are no icons on the 3rd tab
character said:
do you know how to make it 9 tab selection?
and how have you made it as 4 as you can see there are no icons on the 3rd tab
Click to expand...
Click to collapse
answer to you first question starts from this thread: http://forum.xda-developers.com/showthread.php?t=374335&page=14 you need to go into registry and creat one! I know it's tedious but somewhare in that thread there's even cab fix to get all nine icons working.
As for your second question sorry I don't use the the 4 + 1 tab just the 3 + 1 hence there is no iicon but again if you look in the above thread I've mentioned you will find the htc style 4 + 1 tab!
forgive me for being a noob at spb ... how can i make it 3+1? searched the settings for spb mobile shell
>>> now screen
>>>today
>>> animation
>>> tabs
>>> advanced
>>> theme
>>> weather
still there are no options there for 3+1 or 4+1
am @ lost here
or am I the only one that doesn't understand the term? regarding xml how can i edit it? sorry again i am new with spb shell thanks
gfreek said:
I've got colour background on all screens buy editing xml's time,lockscreen,waether,launcher and spb menu by having this class definition:
<Plugin Class="Spb.LSP.GradBackground" Name="Background">
<Int Name="NoBackgrd" Value="0"/>
<Point Name="Separator3Y" X="0" Y="0"/>
However, except one screen the "Classic Now Screen" don't understand why? I'm sure I'm missing something in lockscreen xml???
Click to expand...
Click to collapse
hey, i changed the classic now screen by editing the files "separator.bmp and separator_m.bmp" instead of separator2
e.g.
<Layout Name="Simple">
<Plugins>
<Plugin Class="Spb.LSP.GradBackground" Name="Background"/>
<Int Name="NoBackgrd" Value="1"/>
<Point Name="Separator2Y" X="0" Y="0"/>
or was it..
<Layout Name="Simple">
<Plugins>
<Plugin Class="Spb.LSP.GradBackground" Name="Background"/>
<Int Name="NoBackgrd" Value="1"/>
<Point Name="Separator1Y" X="0" Y="0"/>
each screen has its own links to a separator right, so for different screens, you make new separators (dupe originals, then rename them to something else, so you have extras, now instead of specifying e.g. separator2.bmp, you specify "separator_hey hey new bmp!.bmp")
i'll post up diff bmp ones soon
heres ya go, 3 diff wallpapers
achieved by vertical shift of separator2 (aka 3y)
one of them is the analog layout
asefsef said:
achieved by vertical shift of separator2 (aka 3y)
one of them is the analog layout
Click to expand...
Click to collapse
DO again, more more mdr please
asefsef said:
achieved by vertical shift of separator2 (aka 3y)
one of them is the analog layout
Click to expand...
Click to collapse
Great work.
I edited other xml files with your code. Now I have background image on all screens.

[Q] change background image

how do you change the background image from within the java code (i.e. not within the layout.xml)
hyperbyteX said:
how do you change the background image from within the java code (i.e. not within the layout.xml)
Click to expand...
Click to collapse
Change background image of what? Wallpaper, button...?
The wallpaper
Sent from my GT-I9000M using XDA App
In your layout file, give your layout an id:
<RelativeLayout
android:id="@+id/myLayout"
.......
>
Then in the activity code:
RelativeLayout rl = (RelativeLayout) findViewById(R.id.myLayout);
rl.setBackgroundResource(R.drawable.myNewBackground);
Or are you asking about the homescreen wallpaper for the device?
Lakers16 said:
Or are you asking about the homescreen wallpaper for the device?
Click to expand...
Click to collapse
I think that's what he meant.
Code:
getApplicationContext.setWallpaper()
should do it... But check the documentation for proper syntax.
that only lets me use bitmaps. How do I set it by resource (e.g. "R.drawable.image4")?
Make it a bitmap then:
Bitmap bmp = BitmapFactory.decodeResource(activity.getResources(), R.drawable.img);
activity.getApplicationContext().setWallpaper(bmp);

Animation question.

I have an activity that is a blank screen except for one ImageView object that has it's gravity set to center. Then in my res\anim directory, I animate that image, basically moving it from the bottom of the screen to the center (rising up), using <translate>. What I'm trying to figure out how to do is have the activity load with a blank screen, not showing the ImageView until after the animation finishes with the image centered. What happens right now is the screen shows with the image already in the center, then the animation takes over and moves it from bottom to top. How Can I make the animation happen first, before showing the ImageView?
//Default:
imageView.setVisibility(View.INVISIBLE);
onAnimationStart() {
imageView.setVisibility(View.VISIBLE);
}
The .setVisibilty works, but it's led me to another problem. In my xml layout file for this activity, I only have 2 objects, a TextView at the top of the screen (using LinearLayout) and then an ImageView that is set to.
<LinearLayout
androidrientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<ImageView android:id="@+id/Image01"
android:src="@drawable/image_01"
android:layout_height="150dp"
android:layout_width="200dp"
androidaddingTop="10px"
>
</ImageView>
</LinearLayout>
This puts the image dead center of the screen. What I want the animation to do is have the image rise from the bottom of the screen to the center. The problem is that even if I have the .setVisibility to INVISIBLE in the onCreate, then set to VISIBLE after I start the animation, it still flashes the image in the dead center of the screen (for about half a second), then immediately drops to the bottom and rises back up to center. This looks sloppy. How can I make the image never show until appears at bottom then rise to the center? I beg for specifics, as I'm just getting feet wet with java and xml.
Never mind, this only seems to happen in the emulator. It works fine on the phone.

[Q] Custom progress bar - I need a little help

I'm totally lost right now after trying so many different ways to create a custom progress bar. I'm shooting for something like Catch Notes', it's a perfect example.
Right now, my Action Bar is calling a generic progress bar layout and that works fine. I've attached a picture of what I'm looking for to help even more.
Code:
switch (item.getItemId()) {
case R.id.refresh: //Obviously, this is my refresh Action Bar icon.
item.setActionView(R.layout.progress);
return true;
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar android:id="@+id/progress"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ProgressBar>
</LinearLayout>
http://developer.android.com/reference/android/widget/ProgressBar.html
one second...
i just noticed you are already setting your own style
Code:
style="?android:attr/progressBarStyleSmall"
can you post your progressBarStyleSmall.xml and other relevant drawables, layer-lists, shapes, and animations xml files?
i have been trying to make one of these for a while as well.
killersnowman said:
http://developer.android.com/reference/android/widget/ProgressBar.html
can you post your progressBarStyleSmall.xml and other relevant drawables, layer-lists, shapes, and animations xml files?
i have been trying to make one of these for a while as well.
Click to expand...
Click to collapse
The style I'm referencing is the default Android ProgressBar style for a small progress bar. You just drag the small progress bar into your layout.
k well you should look into making your own style. i have styles on the brain so i thought it was a custom one.

take a screenshot of a nested RelativeLayout

I hope that I posted this thread correctly...
It's my first android app and I am using android studio. I want to get a screenshot of a specifi area.
My xml is in this format:
<LinearLayout>
<RelativeLayout>
<RelativeLayout>
<TextView />
<TextView/>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
The two textviews are overlapping. The one holds an image (with transparency) and the other one, a background color and a text (this is why I have them on a single RelativeLayout and overlapping). I want to get a screenshot of this RelativeLayout. Any help please? Nothing of what I have used worked.

Categories

Resources