我已将我的 android studio 更新到 3.6.1 。一切看起来都很好,但我找不到要查看的 xml 文件代码。他们删除了左侧角选项以查看 xml 文件的设计/代码。现在我怎么能看到它?
我必须上传可以从图库中选择或通过相机拍摄的图像。我已经成功地做到了这一点。但问题是,有时图像大小为 1MB。所以上传到服务器需要更多时间。我需要在上传前调整这张图片的大小。这该怎么做?
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
AlertDialog alertDialog1;
if( requestCode == REQUEST_IMAGE && resultCode == Activity.RESULT_OK ){
try {
FileInputStream in = new FileInputStream(destination);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 10;
imagePath = destination.getAbsolutePath();
Bitmap bmp = BitmapFactory.decodeStream(in, null, options);
//img = (ImageView) findViewById(R.id.imageView1);
int nh = (int) ( bmp.getHeight() * (512.0 / bmp.getWidth()) );
Bitmap scaled = Bitmap.createScaledBitmap(bmp, 512, nh, true);
img.setImageBitmap(scaled);
} catch (Exception e) {
// AlertDialog alertDialog1;
alertDialog1 = new …
Run Code Online (Sandbox Code Playgroud)