How can i display an image as my application background

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

How can i display an image as my application background

Postby surya.n.k » Fri Dec 14, 2007 10:39 am

hi i am new to this,

can any one help,How can i display an image as my application background which is in my drive path...

thanks
surya
surya.n.k
Developer
Developer
 
Posts: 26
Joined: Fri Dec 07, 2007 7:33 am

Top

Postby plusminus » Fri Dec 14, 2007 1:44 pm

Hello

you can probably achieve it like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         TextView v = new TextView(this); // or this.findViewByID(...);
  2.  
  3.         Drawable d = Drawable.createFromPath(pathName);
  4.  
  5.         v.setBackground(d);
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Tell us if it worked :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby surya.n.k » Sat Dec 15, 2007 6:09 am

Hi,

I copied the code and it look like this but this is showing white screen....

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class DrawRect extends Activity {
  2.  
  3.     /** Called when the activity is first created. */
  4.  
  5.     @Override
  6.  
  7.     public void onCreate(Bundle icicle) {
  8.  
  9.         super.onCreate(icicle);
  10.  
  11.        
  12.  
  13.          TextView v = new TextView(this); // or this.findViewByID(...);
  14.  
  15.         Drawable d = Drawable.createFromPath("D:\\android\\wallpaper.png");
  16.  
  17.         v.setBackground(d);
  18.  
  19.         setContentView(R.layout.main);
  20.  
  21.       }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


is there any changes to be made by me....
surya.n.k
Developer
Developer
 
Posts: 26
Joined: Fri Dec 07, 2007 7:33 am

Postby plusminus » Sat Dec 15, 2007 3:04 pm

Hello surya.n.k,

you tried to load an image from your Desktop-PCs HardDisk :!:
That is not possible, as the Emulator is like a Virtual Machine simulated within your Desktop-PC :!:

Try to push a background-image to the virtual-HardDisk of the Emulator (:rarrow: :src: HowTo :larrow:)

Then use a path like:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Drawable d = Drawable.createFromPath("/data/misc/myOwnWallpaper.png");
Parsed in 0.035 seconds, using GeSHi 1.0.8.4

... depending on where you pushed your image to.

Let us know if it worked :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby surya.n.k » Mon Dec 17, 2007 6:22 am

hi,

i am using this two steps

i used previous code it is showing the Textview in light white color

but this two steps i used to draw image dto back ground screen it don't work....

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Drawable d = Drawable.createFromPath("data/misc/Images/DrawRect/wallpaper.png");
  2.  
  3.  
  4.  
  5. this.setBackground(d);
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
surya.n.k
Developer
Developer
 
Posts: 26
Joined: Fri Dec 07, 2007 7:33 am

Postby TokenUser » Mon Dec 17, 2007 8:10 pm

There is an alternate way to do this, but it does make for a static background image (this might be acceptable) ...

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.    android:layout_width="fill_parent"
  3.    android:layout_height="wrap_content"
  4.    android:padding="5dip"
  5.    android:background="@drawable/your_image_file">
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Place a copy of the background image (note - make sure it has the extension in lowercase) in the "/res/drawable" directory of your codebase, and edit your layout file to point to that image.

Sure, you can programmatically change it later using the above methods, but sometimes a simple solution is what is being asked for.
TokenUser
Freshman
Freshman
 
Posts: 5
Joined: Thu Dec 13, 2007 3:02 pm
Location: Lost in States [NC, USA]

Top

Postby plusminus » Mon Dec 17, 2007 8:14 pm

Hello TokenUser,

thx for the suggestion, but i think surya.n.k was asking how to load not from resources, but from the Emulator-Drive. :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby TokenUser » Mon Dec 17, 2007 8:35 pm

plusminus wrote:Hello TokenUser,

thx for the suggestion, but i think surya.n.k was asking how to load not from resources, but from the Emulator-Drive. :)

Regards,
plusminus
Yeah, I suspect that as well, but sometimes you try to do things the way you have always done it ... without realising there is a simpler way to achieve the same result.
TokenUser
Freshman
Freshman
 
Posts: 5
Joined: Thu Dec 13, 2007 3:02 pm
Location: Lost in States [NC, USA]

Postby surya.n.k » Thu Dec 20, 2007 7:55 am

Hi

i want to show images in gallary with slide show how to show them

thanx and regards
surya
surya.n.k
Developer
Developer
 
Posts: 26
Joined: Fri Dec 07, 2007 7:33 am

Postby plusminus » Thu Dec 20, 2007 3:54 pm

Hello surya.n.k,

I'm just making a tutorial on that :D.
Give me an hour or two. :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby plusminus » Thu Dec 20, 2007 6:24 pm

Hello again,

Did it :arrow: :src: here.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby surya.n.k » Fri Dec 21, 2007 11:20 am

Thanxs +-

i am able to draw images...

but the text message is displaying....

i con't able to draw fullscreen images...

regards
surya
surya.n.k
Developer
Developer
 
Posts: 26
Joined: Fri Dec 07, 2007 7:33 am

Postby plusminus » Fri Dec 21, 2007 4:52 pm

Hello surya.n.k,

image and text is being displayed and you want to know how to draw images fullscreen :?:

Didn't we solve it :src: here :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby surya.n.k » Sat Dec 22, 2007 10:49 am

Hi +-

there we wrote in main.xml file but i am asking in the recent tutorial given we are able to draw image from drawable folder but there the text is displayed at the top and the image is displayed .i don't want text, only images are to be showen in the whole screen.............


regards
surya
surya.n.k
Developer
Developer
 
Posts: 26
Joined: Fri Dec 07, 2007 7:33 am

Postby plusminus » Sat Dec 22, 2007 4:53 pm

Hello surya.n.k,

Text is only displayed if you write it somewhere in your code (xml or java):!:
Give us a screenshot of what text is displayed :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top
Next

Return to General

Who is online

Users browsing this forum: No registered users and 5 guests