-
Android学习笔记进阶十二之裁截图片
- package xiaosi.cut;
- import java.io.File;
- import android.app.Activity;
- import android.content.Intent;
- import android.graphics.drawable.Drawable;
- import android.net.Uri;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.ViewGroup.LayoutParams;
- import android.widget.Button;
-
- public class CutActivity extends Activity {
-
- private static int SELECT_PICTURE;
- private File tempFile;
- private Button button;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- this.tempFile = new File("/sdcard/song/a.jpg");
- button = new Button(this);
- button.setText("获取图片");
- button.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
- intent.setType("image/*");
- intent.putExtra("crop", "true");
-
- intent.putExtra("aspectX", 1);
- intent.putExtra("aspectY", 2);
-
- intent.putExtra("output", Uri.fromFile(tempFile));
- intent.putExtra("outputFormat", "JPEG");
-
- startActivityForResult(Intent.createChooser(intent, "选择图片"), SELECT_PICTURE);
- }
- });
- setContentView(button);
- }
-
- /**
- * 裁剪完图片后系统调用的方法:onActivityResult
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode == RESULT_OK)
- if (requestCode == SELECT_PICTURE)
- button.setBackgroundDrawable(Drawable.createFromPath(tempFile.getAbsolutePath()));
- }
- }
-
相关阅读:
详说清除浮动
ie7 z-index 失效问题
ul里不能直接嵌套div(在ie7以前版本)
jQuery 发送验证码倒计时按钮
VBA: Cant find project or librar
InstallShield Limited Edition制作安装文件
InstallShield制作升级安装包
VBA 获取Sheet最大行
求两条线段交点zz
VBA找不到progress bar的处理办法。
-
原文地址:https://www.cnblogs.com/Free-Thinker/p/6721794.html
Copyright © 2020-2023
润新知