I make an application with wallpaper, when you install a picture on the main screen, it (the picture) is clipped in the center, how to make it so that it is not cut off?
My code
private ImageView mImageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.full_image); // get intent data Intent i = getIntent(); // Selected image id int position = i.getExtras().getInt("id"); ImageAdapter imageAdapter = new ImageAdapter(this); mImageView = (ImageView) findViewById(R.id.full_image_view); mImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), imageAdapter.mThumbIds[position])); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int height = metrics.heightPixels; int width = metrics.widthPixels; Bitmap tempbitMap = (BitmapFactory.decodeResource(getResources(), imageAdapter.mThumbIds[position])); Bitmap bitmap = Bitmap.createScaledBitmap(tempbitMap, width, height, true); WallpaperManager wallpaperManager = WallpaperManager.getInstance(FullImageActivity.this); wallpaperManager.setWallpaperOffsetSteps(1, 1); wallpaperManager.suggestDesiredDimensions(width, height); try { wallpaperManager.setBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); Errors
java.lang.IllegalStateException: Could not find a method tempbitMap(View) in the activity class onlyspector.myapplication.FullImageActivity for onClick handler on view class android.widget.Button at android.view.View$1.onClick(View.java:3825) at android.view.View.performClick(View.java:4475) at android.view.View$PerformClick.run(View.java:18786) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5419) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoSuchMethodException: tempbitMap [class android.view.View] at java.lang.Class.getConstructorOrMethod(Class.java:423) at java.lang.Class.getMethod(Class.java:787) at android.view.View$1.onClick(View.java:3818) at android.view.View.performClick(View.java:4475) at android.view.View$PerformClick.run(View.java:18786) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5419) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) at dalvik.system.NativeStart.main(Native Method)