Android碎片积累

Android学习中有很多零碎的知识,做个记录方便查看(连载中………)。

1. 启动系统图库:

//调用系统的图库
Intent intent = new Intent(Intent.ACTION_PICK, null);
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,"image/*");
startActivityForResult(intent,100);

//重写onActivityResult()方法
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 100 && resultCode == RESULT_OK) {
            if (data != null) {
                mPhoto.setImageURI(data.getData());
            }

        }
    }

2. 修改Edittext的字体:

//提前将需要的字体放入assets文件下
word = (EditText) findViewById(R.id.word);    word.setTypeface(Typeface.createFromAsset(getAssets(),"test.ttf"));

3. 获取屏幕截图:

//最后会将屏幕截图作为Bitmap返回
View view = getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
view.getDrawingCache()

你可能感兴趣的:(android)