_path = Environment.getExternalStorageDirectory() + "/images/make_machine_example.jpg";
protected void startCameraActivity()
{
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult( intent, 0 );
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
Log.i( "MakeMachine", "resultCode: " + resultCode );
switch( resultCode )
{
case 0:
Log.i( "MakeMachine", "User cancelled" );
break;
case -1:
onPhotoTaken();
break;
}
}
0和1 是指当你按下开始拍照或者取消拍照时的响应代码
protected void onPhotoTaken()
{
_taken = true;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeFile( _path, options );
_image.setImageBitmap(bitmap);
}
@Override
protected void onSaveInstanceState( Bundle outState ) {
outState.putBoolean( PhotoCaptureExample.PHOTO_TAKEN, _taken );
}
@Override
protected void onRestoreInstanceState( Bundle savedInstanceState){
Log.i( "MakeMachine", "onRestoreInstanceState()");
if( savedInstanceState.getBoolean( PhotoCaptureExample.PHOTO_TAKEN ) ) {
onPhotoTaken();
}
}
前一个是指屏幕旋转前保存 后一个指屏幕旋转完成 保存
今天试了一下渐变的效果 还不错
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:type="radial" android:gradientRadius="250"
android:startColor="#E9E9E9" android:endColor="#D4D4D4" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="0" android:startColor="#FFdaf3fc"
android:centerColor="#FFd4e9a9" android:endColor="#FFdaf3fc"/>
</shape>
在这里要注意android:type="radial"类型的使用会有不同的效果
android:centerColor="#FFd4e9a9" 通常这个也不是被人常用
1. 获取资源的输入流
资源文件 sample.txt 位于 $PROJECT_HOME/assets/ 目录下,可以在 Activity 中通过
Context.getAssets().open(“sample.txt”)
方法获取输入流。
注意:如果资源文件是文本文件则需要考虑文件的编码和换行符。建议使用UTF-8和Unix换行符。
2. WebView 加载assets目录下的html文件资源文件 sample.html 位于 $PROJECT_HOME/assets/ 目录下,可以通过以下代码
WebView.loadUrl(/blog_article/“file_//android_asset/sample.html”);
加载html文件。
[*]