android中Imageview的布局和使用

布局:

 <ImageView
        android:id="@+id/imt_photo"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
       android:layout_marginLeft="0dp"
       android:layout_marginRight="0dp"
        android:layout_marginTop="0dp" >
    </ImageView>

初始化和简单的使用:

private ImageView imageView;
    imageView= (ImageView) findViewById(R.id.imt_photo);
    imageView.setImageBitmap(pic); // 这个ImageView是拍照完成后显示图片

    private static String photoPath = "/sdcard/AnBo/";
    private static String photoName = photoPath + "laolisb.jpg";
    BitmapFactory.Options op = new BitmapFactory.Options();
    op.inSampleSize = 4; // 这个数字越大,图片大小越小,越不清晰
    Bitmap pic = null;
    pic = BitmapFactory.decodeFile(photoName, op);   //从指定的地方获取图片
    imageView.setImageBitmap(pic); //显示图片信息

猜你喜欢

转载自www.cnblogs.com/mlgm/p/9686499.html