[Q] change background image - Android Software Development

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);

Related

How to disable homescreen weather animation?

How to disable homescreen weather animation? Thx
I don't think that this is the right place to ask the question (not relating to rom development). Did you search for it?
If you just change your wallpaper to just a static image, the weather wallpaper is disabled.
Jason
Yes i searched... Some ROMs this choice haven't. Only animated or weather wallpaper, not a static image Thx
Tommy1979 said:
Yes i searched... Some ROMs this choice haven't. Only animated or weather wallpaper, not a static image Thx
Click to expand...
Click to collapse
Choose animated wallpaper then pick your static image.
Simply clever )) THX!
hasan1st said:
Choose animated wallpaper then pick your static image.
Click to expand...
Click to collapse
How do you change your wallpaper to a static image?
Tommy1979 said:
How to disable homescreen weather animation? Thx
Click to expand...
Click to collapse
[HKEY_CURRENT_USER\Software\HTC\Manila]
"Home.WallpaperMode"=dword:00000002
"CachedBackgroundPath"="\\My Documents\\My Wallpapers\\wallpaper_001.png"
"HomeBackgroundPath"="\\My Documents\\My Wallpapers\\wallpaper_001.png"
"Layer2Pageindex"=dword:00000003
copy an 800x800 file renamed wallpaper_001.png
Registry Edit...
Found this on HD2 Forums.. worked like a champ for me on my Imagio and TP2.
-----
Here is the registry edit to enable the weather animation back on again ...!
HKCU/Software/HTC/manila/Home.WallpaperMode
change from dword 1 to dword:0 ........
Here is the registry edit to disable the weather animation ....!
HKCU/Software/HTC/manila/Home.WallpaperMode
change from dword 0 to dword:1 .........

How to cook a default wallpaper

Hi all, i came with a simple problem: how can i cook a wallpaper?
Searching around the forum i've found i have to edit the default wallpaper in the TSK i'm using, the problem is that my TSK doesn't have a default wallpaper, and i don't know how to add one to it.
Can somebody help me?
Add files stwater_<width>_<height>.jpg and stwater_<height>_<width>.jpg where <height> is height for your screen and <width> is width of your screen (eg stwater_480_800.jpg is 480x800 jpg for portrait background and stwater_800_480.jpg is 800x480 jpg for landscape background).
OndraSter said:
Add files stwater_<width>_<height>.jpg and stwater_<height>_<width>.jpg where <height> is height for your screen and <width> is width of your screen (eg stwater_480_800.jpg is 480x800 jpg for portrait background and stwater_800_480.jpg is 800x480 jpg for landscape background).
Click to expand...
Click to collapse
Tried, but i still get the blue default wallpaper. I'm not using the default blue theme, maybe it cares
Cero92 said:
Tried, but i still get the blue default wallpaper. I'm not using the default blue theme, maybe it cares
Click to expand...
Click to collapse
Default Blue Wallpapers name are 'Default_stwater_480_800.gif' and 'Default_stwater_800_480.gif' . You should replace them but it's better to set your default wallpaper with registry entries.
TAEL said:
Default Blue Wallpapers name are 'Default_stwater_480_800.gif' and 'Default_stwater_800_480.gif' . You should replace them but it's better to set your default wallpaper with registry entries.
Click to expand...
Click to collapse
How? I couldn't find anything about it
You have all the necessary in you Operator EXT package.
There are 2 files inside :
Code:
HTC_stwater_480_800.jpg
HTC_stwater_800_480.jpg
Now rename your personal wallpaper like the to below then be sure to have this in your Operator package:
Code:
mxipupdate_HTC1_100.provxml
Now...there is already a thread here in CC that explain your same problem [SOLVED] Cooking theme into Roms you must read it from the 1st post and you will find your solution and if you need more help about theme/wallpapers,please, use that thread because im closing this one, because it is useless have many double threads here.
Cero92 said:
How? I couldn't find anything about it
Click to expand...
Click to collapse

Android animated widget homescreen

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?

[Q] How do I set a color to be transparent ImageView

I have a ImageView with a bitmap on on top of a FrameLayout. To get this bitmap I converted a png w/ transparent background to bitmap. So all the transparency turned into black. How do i set that black to be transparant.
Thankyou
could you be more specific to help you. i can't get your question probably please bare with me. thanks
Only by not using a bitmap. Why did you convert the png (that supports transparency) to a bitmap (that doesn't support transparency) anyway?

layout lost after theme

I want to make an activity to look like the PIN screen . I have a table layout and it looks fine (pic 1), but i want to have as background the wallpaper of the phone.
this code :
Code:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable wallpaperDrawable = wallpaperManager.getDrawable();
gets the wallpaper streched.
so the only way to have the right background is to theme that activity using android:theme="@android:style/Theme.Wallpaper.NoTitleBar".
But then my layout is lost (pic 2).
Can anyone help me ?
Don't use a style.
Just set the layout background, of your activity layout xml, to the wallpaper drawable.
How are you setting your table layout's background?
You set the root layout background using android:background attribute.

Categories

Resources