显示一半的图像在屏幕的底部 [英] Display half of the image at the bottom of the screen

查看:224
本文介绍了显示一半的图像在屏幕的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是在屏幕底部显示半个车轮的形象。我不能削减的形象,因为我需要在运行时旋转。我曾尝试不同的选择相对布局(通过设置这是alignParentBottom为真,并通过给予-ve保证金底部),线性布局(通过给边距)。它的正常MDPI(320X480),华电国际(480X800)设备的工作。但是,当设备的高度增加像(如480X870),然后是越来越显示整个车轮。

My requirement is to display half of a wheel image at bottom of the screen. I can't cut the image, as I need to rotate it at run time. I have tried different options with relative layout(by setting this as alignParentBottom as true and by giving -ve margin bottom), linear layout(by giving margins). Its working for normal mdpi(320X480), hdpi(480X800) devices. But when device's height increases like for (like 480X870) then the entire wheel is getting displayed.

轮式图片

和屏幕看起来应该像为

需要此帮助。先谢谢了。

Need the help regarding this. Thanks in advance.

推荐答案

您总是可以裁剪您通过 Bitmap.createBitmap()静态方法需要一块,和然后将其分配给视图:

You could always crop the piece that you need via the Bitmap.createBitmap() static method, and then assign it to the view:

喜欢的东西...

// Set some constants
private static final Bitmap SOURCE_BITMAP = BitmapFactory.decodeFile(....); // Get the source Bitmap using your favorite method :-)
private static final int START_X = 10;
private static final int START_Y = 15;
private static final int WIDTH_PX = 100;
private static final int HEIGHT_PX = 100;

// Crop bitmap
Bitmap newBitmap = Bitmap.createBitmap(SOURCE_BITMAP, START_X, START_Y, WIDTH_PX, HEIGHT_PX, null, false);

// Assign new bitmap to ImageView
ImageView image = (ImageView)findViewById(R.id.image_view);
image.setImageBitmap(newBitmap);

在这里,你的 SOURCE_BITMAP 是原车的形象。

In here, your SOURCE_BITMAP is your original steering image.

我希望这会有所帮助。

这篇关于显示一半的图像在屏幕的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆