Anybody pls answer this?

On May 5, 4:29 pm, mack2978 <[email protected]> wrote:
> Hi All,
>
> I am trying to set the image as wallpaper from code and it is working
> fine.
> But when i looked the setted wallpaper, it seems to be streched, any
> idea, why it has streched?
>
> below is my code:
> package com.example.HelloGridView;
> import java.io.IOException;
>
> import com.example.HelloGridView.R;
>
> import android.app.Activity;
> import android.app.AlertDialog;
> import android.content.Intent;
> import android.graphics.Bitmap;
> import android.graphics.BitmapFactory;
> import android.graphics.drawable.Drawable;
> import android.os.Bundle;
> import android.util.Log;
> import android.view.View;
> import android.view.Window;
> import android.view.ViewGroup.LayoutParams;
> import android.widget.Button;
> import android.widget.Gallery;
> import android.widget.ImageButton;
> import android.widget.ImageView;
> import android.widget.LinearLayout;
> import android.widget.Toast;
> import android.view.View.OnClickListener;
> import android.app.WallpaperManager;
>
> public class myimageview extends Activity implements OnClickListener {
>     /** Called when the activity is first created. */
>
>         //public MyView myView;
>         int   param1;
>     private ImageView mImageView;
>     private ImageButton setwallpaper;
>     private ImageButton mslideshow;
>     @Override
>     protected void onCreate(Bundle savedInstanceState)
>     {
>         super.onCreate(savedInstanceState);
>         final WallpaperManager wallpaperManager =
> WallpaperManager.getInstance(this);
>         requestWindowFeature(Window.FEATURE_NO_TITLE);
>         Bundle bundle = this.getIntent().getExtras();
>         param1 = bundle.getInt("param1");
>         setContentView(R.layout.myimageview);
>         mImageView = (ImageView) findViewById(R.id.imageview);
>         mImageView.setDrawingCacheEnabled(true);
>         mImageView.setImageResource(param1);
>         mslideshow =
> (ImageButton)findViewById(R.id.slideshow);
>
>         mslideshow.setOnClickListener(new OnClickListener() {
>             public void onClick(View view) {
>
>                     Intent MyIntent = new Intent(myimageview.this,
> slideshowview.class);
>                     startActivity(MyIntent);
>
>             }
>         });
>
>         setwallpaper = (ImageButton) findViewById(R.id.preview);
>         setwallpaper.setOnClickListener(new OnClickListener() {
>             public void onClick(View view) {
>                 try {
>
> wallpaperManager.setBitmap(mImageView.getDrawingCache());
>                     finish();
>                 } catch (IOException e) {
>                     e.printStackTrace();
>                 }
>             }
>         });
>     }
>                 @Override
>                 public void onClick(View v) {
>                         //show message
>                         //Toast.makeText(this, "Button Pressed",
> Toast.LENGTH_LONG).show();
>
>                         }
>
>         }
> thanks,
> mac

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to