三种方式绘制图片
程序员文章站
2022-07-31 21:42:53
1. ImageView 绘制图片 ......
1. ImageView 绘制图片
package com.ddx.testimageview; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Environment; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.widget.ImageView; import java.io.File; public class ShowImageView extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_show_image_view); //Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getPath() + File.separator + "11.jpg"); Bitmap bitmap = BitmapFactory.decodeFile(Environment.getDataDirectory().getPath() + File.separator + "11.jpg"); Log.d("DDX", "externalStorageDirectory = " + Environment.getExternalStorageDirectory().getPath() + File.separator + "11.jpg"); ImageView imageView = (ImageView) findViewById(R.id.imageView); imageView.setImageBitmap(bitmap); } }
上一篇: 搞笑短笑话6个
下一篇: 港片出现率极高的口头语