xiaoguozi's Blog
Pay it forword - 我并不觉的自豪,我所尝试的事情都失败了······习惯原本生活的人不容易改变,就算现状很糟,他们也很难改变,在过程中,他们还是放弃了······他们一放弃,大家就都是输家······让爱传出去,很困难,也无法预料,人们需要更细心的观察别人,要随时注意才能保护别人,因为他们未必知道自己要什么·····

实现全屏函数:



   private void setFullScreen(){ 
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

退出全屏函数:



  private void quitFullScreen(){ 
final WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attrs);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
posted @ 2012-03-17 23:47 小果子 阅读(144) | 评论 (0)编辑 收藏

Android里有两个类
android.view.GestureDetector
android.view.GestureDetector.SimpleOnGestureListener

1)新建一个类继承SimpleOnGestureListener,HahaGestureDetectorListener ,可以实现以下event事件:
boolean  onDoubleTap(MotionEvent e) :双击的第二下Touch down时触发
boolean  onDoubleTapEvent(MotionEvent e) :双击的第二下Touch down和up都会触发,可用e.getAction()区分。
boolean  onDown(MotionEvent e) :Touch down时触发
boolean  onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) :Touch了滑动一点距离后,up时触发。
void  onLongPress(MotionEvent e) :Touch了不移动一直Touch down时触发
boolean  onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) :Touch了滑动时触发。
void  onShowPress(MotionEvent e) :Touch了还没有滑动时触发(onDown只要Touch down一定立刻触发;Touch down后过一会没有滑动先触发onShowPress再是onLongPress;Touch down后一直不滑动,onDown->onShowPress->onLongPress这个顺序触发。)
boolean  onSingleTapConfirmed(MotionEvent e) ,boolean  onSingleTapUp(MotionEvent e) :这两个函数都是在touch down后又没有滑动(onScroll),又没有长按(onLongPress),然后Touchup时触发。
点击一下非常快的(不滑动)Touchup: onDown->onSingleTapUp->onSingleTapConfirmed
点击一下稍微慢点的(不滑动)Touchup: onDown->onShowPress->onSingleTapUp->onSingleTapConfirmed

2)在view的新建一个GestureDetector的对象。
构造函数里:gestureDetector = new GestureDetector(new HahaGestureDetectorListener());
然后在View的onTouchEvent里以下这样用,就可以在刚才1)弄的事件里写自己的代码了。
@Override
public boolean onTouchEvent(MotionEvent event) {
    gestureDetector.onTouchEvent(event);
}

posted @ 2012-03-17 23:46 小果子 阅读(974) | 评论 (0)编辑 收藏


 android 2.0开始 加入的 android.media.ExifInterface 包中如下方法读取相关信息:

 

/*
* 目前Android SDK定义的Tag有:
TAG_DATETIME 时间日期
TAG_FLASH 闪光灯
TAG_GPS_LATITUDE 纬度
TAG_GPS_LATITUDE_REF 纬度参考
TAG_GPS_LONGITUDE 经度
TAG_GPS_LONGITUDE_REF 经度参考
TAG_IMAGE_LENGTH 图片长
TAG_IMAGE_WIDTH 图片宽
TAG_MAKE 设备制造商
TAG_MODEL 设备型号
TAG_ORIENTATION 方向
TAG_WHITE_BALANCE 白平衡
*/ 

 

String sFileName="/sdcard/DCIM/Camera/1.JPG";
try{
ExifInterface exif = new ExifInterface(sFileName);
String sModel=exif.getAttribute(ExifInterface.TAG_MODEL);
Toast.makeText(PhotoCatActivity.this,"1.JPG Exif:"+sModel, Toast.LENGTH_SHORT).show();
}
catch(Exception ee){

}

posted @ 2012-03-17 23:46 小果子 阅读(1147) | 评论 (0)编辑 收藏

001package cn.m15.test;
002 
003import java.io.ByteArrayOutputStream;
004import java.io.File;
005import android.app.Activity;
006import android.content.Intent;
007import android.graphics.Bitmap;
008import android.net.Uri;
009import android.os.Bundle;
010import android.os.Environment;
011import android.provider.MediaStore;
012import android.view.View;
013import android.view.View.OnClickListener;
014import android.widget.Button;
015import android.widget.ImageView;
016 
017public class testActivity extends Activity {
018 
019    public static final int NONE = 0;
020    public static final int PHOTOHRAPH = 1;// 拍照
021    public static final int PHOTOZOOM = 2; // 缩放
022    public static final int PHOTORESOULT = 3;// 结果
023 
024    public static final String IMAGE_UNSPECIFIED = "image/*";
025    ImageView imageView = null;
026    Button button0 = null;
027    Button button1 = null;
028 
029    @Override
030    public void onCreate(Bundle savedInstanceState) {
031        super.onCreate(savedInstanceState);
032        setContentView(R.layout.main);
033        imageView = (ImageView) findViewById(R.id.imageID);
034        button0 = (Button) findViewById(R.id.btn_01);
035        button1 = (Button) findViewById(R.id.btn_02);
036 
037        button0.setOnClickListener(new OnClickListener() {
038            @Override
039            public void onClick(View v) {
040                Intent intent = new Intent(Intent.ACTION_PICK, null);
041                intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_UNSPECIFIED);
042                startActivityForResult(intent, PHOTOZOOM);
043            }
044        });
045 
046        button1.setOnClickListener(new OnClickListener() {
047 
048            @Override
049            public void onClick(View v) {
050                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
051                intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "temp.jpg")));
052                startActivityForResult(intent, PHOTOHRAPH);
053            }
054        });
055    }
056 
057    @Override
058    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
059        if (resultCode == NONE)
060            return;
061        // 拍照
062        if (requestCode == PHOTOHRAPH) {
063            //设置文件保存路径这里放在跟目录下
064            File picture = new File(Environment.getExternalStorageDirectory() + "/temp.jpg");
065            startPhotoZoom(Uri.fromFile(picture));
066        }
067         
068        if (data == null)
069            return;
070         
071        // 读取相册缩放图片
072        if (requestCode == PHOTOZOOM) {
073            startPhotoZoom(data.getData());
074        }
075        // 处理结果
076        if (requestCode == PHOTORESOULT) {
077            Bundle extras = data.getExtras();
078            if (extras != null) {
079                Bitmap photo = extras.getParcelable("data");
080                ByteArrayOutputStream stream = new ByteArrayOutputStream();
081                photo.compress(Bitmap.CompressFormat.JPEG, 75, stream);// (0 - 100)压缩文件
082                imageView.setImageBitmap(photo);
083            }
084 
085        }
086 
087        super.onActivityResult(requestCode, resultCode, data);
088    }
089 
090    public void startPhotoZoom(Uri uri) {
091        Intent intent = new Intent("com.android.camera.action.CROP");
092        intent.setDataAndType(uri, IMAGE_UNSPECIFIED);
093        intent.putExtra("crop", "true");
094        // aspectX aspectY 是宽高的比例
095        intent.putExtra("aspectX", 1);
096        intent.putExtra("aspectY", 1);
097        // outputX outputY 是裁剪图片宽高
098        intent.putExtra("outputX", 64);
099        intent.putExtra("outputY", 64);
100        intent.putExtra("return-data", true);
101        startActivityForResult(intent, PHOTORESOULT);
102    }
103}

01<?xml version="1.0" encoding="utf-8"?>
02<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
03    android:orientation="vertical" android:layout_width="fill_parent"
04    android:layout_height="fill_parent">
05    <TextView android:layout_width="fill_parent"
06        android:layout_height="wrap_content" android:text="@string/hello" />
07    <ImageView android:id="@+id/imageID"
08        android:adjustViewBounds="true" android:maxWidth="50dip"
09        android:maxHeight="50dip" android:layout_width="wrap_content"
10        android:layout_height="wrap_content" />
11    <Button android:id="@+id/btn_01" android:layout_height="50dip"
12            android:text="相册" android:layout_width="150dip"/>
13    <Button android:id="@+id/btn_02" android:layout_height="50dip"
14            android:text="拍照" android:layout_width="150dip"/>
15</LinearLayout>


posted @ 2012-03-15 12:12 小果子 阅读(481) | 评论 (0)编辑 收藏
package com.twy.test;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class testDemo extends Activity {
    private LinearLayout lay;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        lay = (LinearLayout) findViewById(R.id.linearLayout1);

        firstLay();
    
    }

    private void firstLay() {
        Bitmap mbitmap_c = BitmapFactory.decodeResource(getResources(),
                R.drawable.cc);
        Bitmap mbitmap_b = BitmapFactory.decodeResource(getResources(),
                R.drawable.bb);
        Bitmap mbitmap_e = BitmapFactory.decodeResource(getResources(),
                R.drawable.ee);
        Bitmap mbitmap_f = BitmapFactory.decodeResource(getResources(),
                R.drawable.ff);
        
        Drawable[] array = new Drawable[4];
        array[0] = new BitmapDrawable(mbitmap_b);
        array[1] = new BitmapDrawable(mbitmap_c);
        array[2] = new BitmapDrawable(mbitmap_e);
        array[3] = new BitmapDrawable(mbitmap_f);
        
        LayerDrawable la = new LayerDrawable(array);
        la.setLayerInset(0, 0, 0, 0, 0);
        la.setLayerInset(1, 80, 0, 0, 0);
        la.setLayerInset(2, 160, 0, 0, 0);
        la.setLayerInset(3, 240, 0, 0, 0);
        
        ImageView img = new ImageView(this);
        img.setImageDrawable(la);
        
        lay.addView(img);
        
    }
}
posted @ 2012-03-15 10:44 小果子 阅读(354) | 评论 (0)编辑 收藏
仅列出标题
共58页: First 16 17 18 19 20 21 22 23 24 Last