如何从Android工作室检索和处理图像文件?

时间:2017-05-10 01:40:10

标签: javascript android-studio file-io

如何获取图像文件,然后读取图像文件的名称?

我不知道位图的工作原理。

1 个答案:

答案 0 :(得分:0)

1)将图像移动到drawable文件夹

2)在您活动的XML布局文件(例如ActivityMain.xml)中添加:
<ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/myImage" android:id="@+id/myImage" />

3)你需要位图的地方: Bitmap bm = ((BitmapDrawable) ((ImageView) findViewById(R.id.cImg)).getDrawable()).getBitmap();

此外,Java不是JavaScript,请删除您的标记。继续编码!