相关疑难解决方法(0)

如何在Android中调整位图大小?

我从远程数据库中获取了一个Base64字符串的位图,(encodedImage是用Base64表示图像的字符串):

profileImage = (ImageView)findViewById(R.id.profileImage);

byte[] imageAsBytes=null;
try {
    imageAsBytes = Base64.decode(encodedImage.getBytes());
} catch (IOException e) {e.printStackTrace();}

profileImage.setImageBitmap(
    BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)
);
Run Code Online (Sandbox Code Playgroud)

profileImage是我的ImageView

好的,但是我必须在显示我ImageView的布局之前调整此图像的大小.我必须将其调整为120x120.

有人能告诉我调整大小的代码吗?

我找到的示例无法应用于获得位图的base64字符串.

base64 android bitmap

314
推荐指数
8
解决办法
41万
查看次数

从文件路径显示图像视图?

我需要仅使用文件名来显示图像,而不是使用资源ID.

ImageView imgView = new ImageView(this);
imgView.setBackgroundResource(R.drawable.img1);
Run Code Online (Sandbox Code Playgroud)

我在drawable文件夹中有图像img1.我希望从文件中显示该图像.

我怎样才能做到这一点?

android imageview android-imageview android-file

288
推荐指数
8
解决办法
44万
查看次数

android drawable from file path

我有一个文件路径字符串形式为"e:\ ...\xxx.jpg"如何从中创建一个drawable?

android filepath drawable

42
推荐指数
1
解决办法
5万
查看次数