我怎样才能显示图像在Android应用程序 [英] How can I display image in Android Application
本文介绍了我怎样才能显示图像在Android应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的特定大小的Android应用程序的显示图像。 我该怎么办呢?请指导我? 还有一件事我想从SD卡的图像。 所以,请帮助我。
I want to display Image in my Android application in specific size. How can I do it? Please guide me? And one more thing I want that image from SD card. So please Help me.
在此先感谢。
推荐答案
首先,你需要创建一个ImageView的。
First you need to create an imageview.
ImageView imageView = new ImageView(getApplicationContext());
创建布局参数添加的ImageView的布局
Create layout param to add imageview on layout
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
然后让你的图片路径
Then get your image path
String path = Environment.getExternalStorageDirectory() + "/your folder name/image_name.bmp";
在ImageView的设置你的形象
Set your image on ImageView
Bitmap image = BitmapFactory.decodeFile(path);
imageView.setImageBitmap(image);
取布局上要添加
Fetch your layout on which you want to add
RelativeLayout rl = (RelativeLayout) findViewById(R.id.relativeLayout1);
添加您的视角以布局
rl.addView(imageView, lp);
这篇关于我怎样才能显示图像在Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文