1.EditText自动弹出软键盘及软键盘遮挡EditText:
2.点击图片放大效果实现:
清单文件里设置activity属性:
android:windowSoftInputMode="adjustPan"
2.点击图片放大效果实现:
第一步将ImageView里的图片传到Activity:
Intent intent = new Intent(ResultActivity.this, ImageActivity.class);
intent.putExtra("image", Bitmap2Bytes(Bitmap.createBitmap(image.getDrawingCache())));
startActivity(intent);
private byte[] Bitmap2Bytes(Bitmap bm){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 80, baos);
return baos.toByteArray();
}
Activity里显示图片:
Intent intent = getIntent();
byte buff[] = intent.getByteArrayExtra("image");
iv.setImageBitmap(BitmapFactory.decodeByteArray(buff, 0, buff.length));
注意:使用image.getDrawingCache()前需设置:image.setDrawingCacheEnabled(true);使用之后不要设置image.setDrawingCacheEnabled(false),否则再次放大图片会报错。
第二步重新获取图片并显示。因为此时Activity显示的是与ImageView里一般大小的图片。3.变量的引用:
for(int i=0;i<jsonArr.length();i++){
ProductBean productBean = new ProductBean();
productBean.setProductCode(productCode);
productBean.setProductName(productName);
temp_list.add(productBean);
}
ProductBean productBean = new ProductBean();不可以放到for循环外面,否则会导致temp_list所有的数据都变成productBean最后一次set的值。
4.获取drawable里的图片并保持原始尺寸:
private Bitmap decodeResource(Resources resources, int id) {
TypedValue value = new TypedValue();
resources.openRawResource(id, value);
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inTargetDensity = value.density;
return BitmapFactory.decodeResource(resources, id, opts);
}
5.ImageView被图片撑大:
设置图片宽为match_parent,高为wrap_content,此时如果图片原始尺寸宽度大于parent,那么ImageView的高会被撑大,这时需设置:
android:adjustViewBounds="true"